Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON Validation Expecting 'EOF'

Tags:

json

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;

],
[
like image 644
Jordan.J.D Avatar asked Mar 03 '14 16:03

Jordan.J.D


1 Answers

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"}
    ]
}
like image 177
T.J. Crowder Avatar answered Sep 18 '22 18:09

T.J. Crowder