Jordan.J.D Jordan.J.D - 4 months ago 17
JSON Question

JSON Validation Expecting 'EOF'

I am working on a restful api and have been validating with http://jsonlint.com/. After combining two JSON objects I ran into;

Parse error on line 932:
...ssions": 329 }],[ { "m
---------------------^
Expecting 'EOF'


I looked around and found this question but all of the answers point to not having a comma, where in my problem I do have a comma. What else could the validator be looking for?

it is pointing at the code between my object arrays;

],
[

Answer

You haven't shown enough of your JSON, but I'm guessing it looks like this:

[
    {"some": "object"},
    {"some": "object"}
],
[
    {"some": "object"},
    {"some": "object"}
]

...which is invalid. In JSON, there must be one top-level item (which in a complete JSON document must either an object or an array).

If you're combining two responses, you might make each of them the value of a property on a wrapper object, e.g.:

{
    "response1": [
        {"some": "object"},
        {"some": "object"}
    ],
    "response2": [
        {"some": "object"},
        {"some": "object"}
    ]
}
Comments