I am trying to import json file into R. For the purpose I am using packages such as rjson
, jsonlite
, RJSONIO
, etc. I have tried different things as shown below but I got errors with all of them.
mydata <- fromJSON(paste(readLines("result_prod_14-15_08_17.json"), collapse=""))
The error I got is:
Error: lexical error: invalid char in json text.
{ "_id" : ObjectId("59920f495401ac79452a0
(right here) ------^
Using 'RJSONIO' package:
md <- stream_in(file("result_prod_14-15_08_17.json"))
produces the following error:
opening fileconnectionoldClass input connection.
Error: parse error: premature EOF
{
(right here) ------^
closing fileconnectionoldClass input connection.
It must be something straightforward but since I am new to R I struggle to figure it out.