Unable to parse JSON files


I am unable to parse the JSON files available for download (using the jsonlite package in R). I have tried both drugs, targets etc, but all return the same error:

Error in parse_con(txt, bigint_as_char) : parse error: trailing garbage
k/drug/moclobemide.html"]}]} {“actionType”:“ANTAGONIST”,"mec
(right here) ------^

If you are keen on R, I would suggest you to try with the sparklyr tutorial in Documentation. That should circumvent some of the issues you are having.

The main reason why this is not working for you, it’s that the files are in JSON lines not in JSON.

OK, thanks for the swift response. From the single example looking into ClinVar it is not clear how a similar approach should be modified for targets/molecules/drugs etc? In particular, I do not understand how the local downloads of the parquet files (which I assume is necessary for this to be working?) should be arranged?

What should be present/downloaded in “/Users/OpenTargetsUser/Datasets” for the example to work?

Although the spark approach is likely a convenient and efficient approach (my first time exposed to parquet, I must admit :-)), showing how the JSON data can be accessed or parsed would in my opinion be highly valuable to the community, considering that this is a well-established format.

1 Like

Seems I now manage to load the JSON data in R (example with targets):

con ← file(‘targets-part-00000.json’,‘r’)
target_data ← jsonlite::stream_in(con)

1 Like