I am using fromJSON
from the jsonlite
package in [R]
to call GetPlayerSummaries
from the Steam API (https://developer.valvesoftware.com/wiki/Steam_Web_API) to get access to a user's data. For most calls it's working fine, but at some point I get an error:
Error in feed_push_parser(readBin(con, raw(), n), reset = TRUE) :
lexical error: invalid bytes in UTF8 string.
publicâ„¢ II: The Sith Lordsâ", "gameid": "208580" },
(right here) ------^
When I access the call in my browser I find a � on the spot where it is probably giving the error. I could Try-Catch but I'd really like to get this data. How to get around this?
For my purpose, reading with readLines
and then parsing it seemed to work
readlines <- readLines(link, warn = FALSE)
parse <- fromJSON(readlines)
I have no idea why and how this works, and may hence be not the most clean solution, but it seems to be robust for my purposes.
You have to use use jsonlite's streaming function
json_file <- stream_in(file("abc.json"))
It has been answered in Stack Overflow here:
Error parsing JSON file with the jsonlite package
and here:
Export JSON from Spark and input into R
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