I\'m trying to read a JSON file into R but I got this error:
Error in parseJSON(txt) : parse error: trailing garbage
[ 33.816101, -117.979401 ] } { \"
This format called ndjson and designed to stream import (including the gzip). Just use this:
con <- url("http://1usagov.measuredvoice.com/bitly_archive/usagov_bitly_data2013-05-17-1368832207.gz")
mydata <- jsonlite::stream_in(gzcon(con))
Or alternatively use the curl package for better performance or to customize the http request:
library(curl)
con <- curl("http://1usagov.measuredvoice.com/bitly_archive/usagov_bitly_data2013-05-17-1368832207.gz")
mydata <- jsonlite::stream_in(gzcon(con))