How can make sure that the result of my getURL()
call is properly formatted to be parsed using from JSON?
Details
If I take the string for api URL and paste that into Chrome, then copy and paste out the resulting JSON, RJSONIO::fromJSON()
will parse it. However, if I pass the variable test, as in my code below, to fromJSON()
, I get this error:
Error in fromJSON(content, handler, default.size, depth, allowComments, : invalid JSON input
In going through the differences between the two, I found some issues encoding escaped character sequences such as "\\\"\\\\\\\""
which I am able to search for and replace. However there are some other things, where for example, the broken JSON will show " "
while the working JSON will show "\u00A0".
library(RJSONIO)
library(RCurl)
apiURL= #sorry I can't post the actual URL due to company security policies
test<-getURL(apiURL,userpwd="myusername:mypassword",httpauth=1L)
transcripts1 <- fromJSON(test)