当我尝试从 Facebook URL 的字符对象解析 JSON 时,我收到“fromJSON(data) 中的错误:位置 130 处出现意外的转义字符 '\o'”。看一下这个:
library(RCurl)
library(rjson)
data <- getURL("https://graph.facebook.com/search?q=multishow&type=post&limit=1500", cainfo="cacert.perm")
fbData <- fromJSON(data)
Error in fromJSON(data) : unexpected escaped character '\o' at pos 130
#with RSONIO also error
> fbData <- fromJSON(data)
Erro em fromJSON(content, handler, default.size, depth, allowComments, :
invalid JSON input
在我尝试解析 JSON 之前,有什么方法可以替换这个 '\o' 字符吗?我尝试了 gsub 但它不起作用(或者我做错了什么)。
datafixed <- gsub('\o',' ',data)
Error: '\o' is an unrecognized escape sequence in string starting with "\o"
有人可以帮我解决这个问题吗?谢谢。
你需要逃离\
在你的模式中。
Try
gsub('\\o',' ',data)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)