0

I have Json file and I am trying to import the data into R Studio I installed rjson and jsonlight library , I used this command

game1 <- fromJSON("/Users/ludn/Desktop/game1.json")

But I got this error

Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage
        "challenge0Time" : "2.8" } {   "challenge0" : [     {     
                 (right here) ------^

What is the problem?

user3490634
  • 9
  • 1
  • 3
  • 1
    try fromJSON(paste(readLines(/Users/ludn/Desktop/game1.json), collapse="")) – Aleksandr Mar 20 '17 at 16:36
  • 1
    Have you tried to check if the JSON is correct? https://jsonformatter.curiousconcept.com/ – takje Mar 20 '17 at 16:42
  • 1
    Besides, this is not really a reproducible example and we can only guess what goes wrong. Try cleaning up your json file until it is small enough to post it here (~few lines, no MBs). Usually you already find your mistake by trying to create a reproducible example. This is because you can pinpoint the exact issue. – takje Mar 20 '17 at 16:57
  • Yes my json file is correct – user3490634 Mar 20 '17 at 18:21
  • actually it was working before – user3490634 Mar 20 '17 at 18:21
  • @user3490634, in that case I refer again to my previous comment on the reproducible example. Without it, it is difficult for us to help you since we cannot reproduce your error and it seems dependent on the input in game1.json. There are some great tips in the first answer on this question: http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example – takje Mar 20 '17 at 18:54
  • Linux users (with systemd), here is a reproducible example of a similar problem (same sort of error message) I discovered when trying to parse my system logs: `tmp <- timefile(); system2("journalctl", c("--no-pager", "--output json"), stdout = tmp); library(jsonlite); jrnl <- read_json(tmp)`. – wdkrnls Jul 08 '17 at 03:42

0 Answers0