Skip to main content

Hi,

The JSON format I get out of the API when I extract multiple Activities is not following JSON standards as it seems. I am not an expert not a dev. But if I pretty print it and save the output, and load it for further analysis, it says the file format is not valid.

I've tried to debut it and indeed I get “multiple JSON root elements”.

Any idea? :)

Thx for your help!

Maybe your analysis prgram has a bug or the json got distorted in the printing and saving process. The activities endpoint creates a json array, a single root is not expected here.


How are you getting the JSON output? The general format for the returned array should look something like this, where the entire output is enclosed in square brackets [] indicating an array, and each activity is enclosed in curly braces {} as an entry in the array.

[
{
"resource_state" : 2,
"athlete" : {
"id" : 1,
"resource_state" : 1
},
"name" : "Activity #1",
"other_fields" : "values"
},
{
"resource_state" : 2,
"athlete" : {
"id" : 1,
"resource_state" : 1
},
"name" : "Activity #2",
"other_fields" : "values"
}
]

If you are seeing multiple root elements, maybe you missed copying the enclosing square brackets around the whole thing? You could also try running the JSON through https://jsonlint.com/ to see what problems it highlights.


Reply