I need to remove all the backslash from the json file i have generated.The json file contains following data
{\"id\":\"650552e7-d0e2-43fc-8eba-50179830fc58\",\"guid\":\"KB0053\",\"kb_category\":\"General\",\"title\":\"Guides VoIP\",\"link\":\"https://instance_name.service-now.com/kb_sysparm_article=KB0016853\",\"doc_id\":\"KB0853\",\"doc_type\":\"customer:nys\",\"content\":\"nTelephony User Guides VoIPn<U+613C><U+3E30>n<U+613C><U+3E30>nCisco 7911 Phone Reference GuideCisco 9900 Series Phone Reference GuideCisco ITS Locations Unity Voicemail Reference GuideCisco DSHES Locations Unity Reference GuideAvaya 1600 Series Phone Reference Phone Reference GuideCisco 6900 Series Phone Reference Series Phone Reference Guide\",\"keywords\":\"Telephony User Guides VoIP, VOIP\",\"abstract\":\" User Guides VoIP\"}
I have tried the following but no luck:
gsub("\\\\", "" ,RNR_json)
gsub("\\\\", "", str)
Not entirely sure if this answers your question, but the problem is that R uses " to start/end strings and any " inside the string needs to be escaped. In that sense your string does not really contain any real backslashes. The backslashes in your string is because your string contains numerous "s. If you use the jsonlite package to parse the JSON string then everything is read correctly as shown below
library(jsonlite)
x <- '{\"id\":\"650552e7-d0e2-43fc-8eba-50179830fc58\",\"guid\":\"KB0053\",\"kb_category\":\"General\",\"title\":\"Guides VoIP\",\"link\":\"https://instance_name.service-now.com/kb_sysparm_article=KB0016853\",\"doc_id\":\"KB0853\",\"doc_type\":\"customer:nys\",\"content\":\"nTelephony User Guides VoIPn<U+613C><U+3E30>n<U+613C><U+3E30>nCisco 7911 Phone Reference GuideCisco 9900 Series Phone Reference GuideCisco ITS Locations Unity Voicemail Reference GuideCisco DSHES Locations Unity Reference GuideAvaya 1600 Series Phone Reference Phone Reference GuideCisco 6900 Series Phone Reference Series Phone Reference Guide\",\"keywords\":\"Telephony User Guides VoIP, VOIP\",\"abstract\":\" User Guides VoIP\"}'
result <- fromJSON(x)
result
which parses the string correctly as seen in the output:
> result
$id
[1] "650552e7-d0e2-43fc-8eba-50179830fc58"
$guid
[1] "KB0053"
$kb_category
[1] "General"
$title
[1] "Guides VoIP"
$link
[1] "https://instance_name.service-now.com/kb_sysparm_article=KB0016853"
$doc_id
[1] "KB0853"
$doc_type
[1] "customer:nys"
$content
[1] "nTelephony User Guides VoIPn<U+613C><U+3E30>n<U+613C><U+3E30>nCisco 7911 Phone Reference GuideCisco 9900 Series Phone Reference GuideCisco ITS Locations Unity Voicemail Reference GuideCisco DSHES Locations Unity Reference GuideAvaya 1600 Series Phone Reference Phone Reference GuideCisco 6900 Series Phone Reference Series Phone Reference Guide"
$keywords
[1] "Telephony User Guides VoIP, VOIP"
$abstract
[1] " User Guides VoIP"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With