0

I was trying to open a JSON file using fromJSON or read_json from jsonlite package, but it does not work and I keep receiving the following message:

My code is:

fromJSON("Kickstarter_2015-06-12.json", flatten=TRUE)


> Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage
          rency_trailing_code": true}} {"id" : 87222572, "robot_id" : 
                     (right here) ------^

Any suggestions?

thelatemail
  • 91,185
  • 12
  • 128
  • 188
useR
  • 179
  • 3
  • 13
  • Looks like you're missing a comma between the JSON objects. Or, you have what is known as NDJSON. see https://stackoverflow.com/q/50430510/5977215 – SymbolixAU Jun 06 '18 at 23:49
  • The error code is pointing you to something being wrong in the section starting with the `"id" = 87222572` - I'd have an eyeball around there in a text editor if possible. Is this the file by the way - https://webrobots.io/kickstarter-datasets/ ? – thelatemail Jun 06 '18 at 23:52
  • Hello, yes exactly it is from webrobots' Kickstarter tracker. seems like I cannot open their JSON files. – useR Jun 07 '18 at 00:09

2 Answers2

1
gzf <- system.file("extdata", "testgz.json.gz", package="ndjson")
nrow(stream_in(gzf))

Or

mydata <- stream_in(file(tmp))
nrow(mydata)

# stream over HTTP
diamonds2 <- stream_in(url("http://jeroen.github.io/data/diamonds.json"))

Some great examples

Streaming JSON Input/Output

Stream In & Flatten An Ndjson File Into A Tbl_dt

Lex
  • 4,749
  • 3
  • 45
  • 66
0

Answer is: ndjson::stream_in()

useR
  • 179
  • 3
  • 13