Hi! You can download the example file with this link: https://www.dropbox.com/s/tlf1gkym6d83log/example.json?dl=0 BTW, I have used a JSON validator and the problem seems to related to wrong/missing EOF. --- snip --- Error: Parse error on line 1: ...:"1436705823768"} {"created_at":"Sun J ---------------------^ Expecting 'EOF', '}', ',', ']', got '{' --- snip --- However, editing the file with a text editor to create "proper" EOF doesn't help. -Kimmo- 23.10.2015, 22:52, Duncan Murdoch wrote:> It looks like it's the same sort of problem as in that stackoverflow > posting: what's in your file is not valid Javascript, so it's not valid > JSON. It's probably multiple JSON objects without proper separators; > you need to do the separating yourself. > > BTW, your attachment failed; only some file types are allowed. You > should probably put the file online somewhere and post the URL. > > Duncan Murdoch
On 24/10/2015 12:11 AM, K. Elo wrote:> Hi! > > You can download the example file with this link: > https://www.dropbox.com/s/tlf1gkym6d83log/example.json?dl=0 > > BTW, I have used a JSON validator and the problem seems to related to > wrong/missing EOF. > > --- snip --- > Error: Parse error on line 1: > ...:"1436705823768"} {"created_at":"Sun J > ---------------------^ > Expecting 'EOF', '}', ',', ']', got '{' > --- snip --- > > However, editing the file with a text editor to create "proper" EOF > doesn't help.The problem is that you have valid-looking JSON objects on each odd numbered line, separated by single blank lines. The parser expects an EOF at the end of the first object, but instead it found a blank line and another object. So just use readLines to read all the lines, and individually convert the ones that are not blank. Duncan Murdoch> > -Kimmo- > > 23.10.2015, 22:52, Duncan Murdoch wrote: >> It looks like it's the same sort of problem as in that stackoverflow >> posting: what's in your file is not valid Javascript, so it's not valid >> JSON. It's probably multiple JSON objects without proper separators; >> you need to do the separating yourself. >> >> BTW, your attachment failed; only some file types are allowed. You >> should probably put the file online somewhere and post the URL. >> >> Duncan Murdoch > > ______________________________________________ > R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. >
On Sat, Oct 24, 2015 at 1:35 PM, Duncan Murdoch <murdoch.duncan at gmail.com> wrote:> > > However, editing the file with a text editor to create "proper" EOF > > doesn't help. > > The problem is that you have valid-looking JSON objects on each odd > numbered line, separated by single blank lines. The parser expects an > EOF at the end of the first object, but instead it found a blank line > and another object.Actually this is a common json streaming format called ndjson a.k.a. jsonlines. Usually you can stream-import the data directly in jsonlite using the stream_in function. See ?stream_in for examples. However in this case there are white lines in between the json lines which makes it a bit more tricky. I will add a feature to skip over those lines.