Varun
Varun

Reputation: 1321

R Parsing error when trying to import JSON to R

I've got a JSON file that looks like this

I am trying to import it into R using the jsonlite package.

#Load package for import
library(jsonlite)
df <- fromJSON("test.json")

But it throws an error

Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage ome in at a later time." } { "id": "e5fa37f44557c62ee (right here) ------^

I've tried looking at all solutions on stackoverflow, but haven't been able to figure this out.

Any inputs would be very helpful.

Upvotes: 1

Views: 941

Answers (1)

St&#233;phane Laurent
St&#233;phane Laurent

Reputation: 84519

The JSON file you linked contains two JSON objects. Perhaps you want an array:

[
{
    "id": "71bb8883780bb152e4bb4db976bedc62",
    "metadata": {
        "abc_bad_date": "true",
        "abc_client": "Hydra Corp",
        "abc_doc_id": 1,
        "abc_file": "Hydra Corp 2016.txt",
        "abc_interview_type": "Post Analysis",
        "abc_interviewee_role": "Director Corporate Engineering; Greater Chicago Area; Global Procurement Director Facilities and MRO",
        "abc_interviewer": "Piper Thomas",
        "abc_services_provided": "Food",
        "section": "on_expectations"
    },
    "text": "Gerrit: There were a number ...."
},
{
    "id": "e5fa37f44557c62eef44baafb13128f0",
    "metadata": {
        "abc_bad_date": "true",
        "abc_client": "Hydra Corp",
        "abc_doc_id": 1,
        "abc_file": "Hydra Corp 2016.txt",
        "abc_interview_type": "Post Analysis",
        "abc_interviewee_role": "Director Corporate Engineering; Greater Chicago Area; Global Procurement Director Facilities and MRO",
        "abc_interviewer": "Piper Thomas",
        "abc_services_provided": "Painting",
        "section": "on_relationships"
    },
    "text": "Gerrit: I thought the  ABC ..."
}
]

Upvotes: 1

Related Questions