JSOn

man… I hate JSON, it’s so hard… something like this is simple…


{
    "Name": "Beatles",
    "Country": "England",
    "YearFormed": 1959,
    "Style": "Rock'n'Roll",
    "Members": [
        "Paul",
        "John",
        "George",
        "Ringo"
    ]
}

but how do I add a second band?

if I add a comma at the end, and repeat, with a diff band name, it doesn’t validate in JSON Lint, i.e., this doesn’t validate…

{
    "Name": "Beatles",
    "Country": "England",
    "YearFormed": 1959,
    "Style": "Rock'n'Roll",
    "Members": [
        "Paul",
        "John",
        "George",
        "Ringo"
    ]
},
{
    "Name": "Rolling Stones",
    "Country": "England",
    "YearFormed": 1956,
    "Style": "Rock'n'Roll",
    "Members": [
        "Mick",
        "Keith",
        "Brian",
        "Charlie"
    ]
}

all the JSON tutorials have really simple examples, but when you get to the real world JSON’s can be very complex…

I need examples of more complex JSON examples to practice with…

thank you…

Your JSON is actually valid, the JSON linter I find to be a bit glitchy as it expects a very specific array to be passed to it but in saying that you shouldn’t have any problem with the above if you wrap it with []

[{
    "Name": "Beatles"
}, {
    "Name": "Rolling Stones"
}]

thank you…

ok, so you can wrap a JSON in either {…} or […]

where can I find some literature on this??

JSON syntax is complex… I need documentation…

(and is there a more reliable validator, then, than Lint?)

thank you…

No you can only use the square brackets as its a collection of values, trying to wrap a JSON object using curly brackets would cause a syntax error as objects require a key to be associated with each individual array index.