I am using R's RJSONIO to read json from a file. The json contains unicode characters, which get read incorrectly.
The code works when the json is passed as string as shown by the author of the R package in the question on stackoverflow How to correctly deal with escaped Unicode Characters in R e.g. the em dash (—).
However when the json is read from a file, it does not produce the correct unicode representation. As seen below:
fromJSON(content="~/MTS/temp")
$query
$query$categorymembers
$query$categorymembers[[1]]
$query$categorymembers[[1]]$ns
[1] 0
$query$categorymembers[[1]]$title
[1] "Banach\023Tarski paradox"
Where ~/MTS/temp contains:
{"query":{"categorymembers":[{"ns":0,"title":"Banach\u2013Tarski paradox"}]}}`
fromJSON(content='{"query":{"categorymembers":[{"ns":0,"title":"Banach\u2013Tarski paradox"}]}}')and it returned[1] "Banach–Tarski paradox"just fine. Are you saying the file literally has an\uin it? How did you create such a JSON file?\uin a JSON file isn't valid (if you want the subsequent number to be considered as unicode character). How are you creating an invalid JOSN file in the first place?rsjsoniolibrary has a parsing bug, you can contact the maintainer (maintainer("rjsonio")) and report it. If therjsonlibrary works the way you want, then use that one.