Why are there commas between objects in JSON?

Viewed 1311

So we've got some JSON that looks like this:

"myBigObj": { 
  "myFirstSmallerObj": { 
    "attr1": 42, // in fact!? you could even git rid of these commas too, if all keys are "keys"?
    "attr2": 43 
  }, 
  "mySecondSmallerObj": { 
    "attr1": true, 
    "attr2": false 
  }  
}

Now, I can see why you've got to have commas between attributes - it delimits the key:value parts, so you can tell where attr1: 42 begins and ends (as opposed to attr1:trueattr2:false).

Which brings me to my question: Why are there commas between objects? It seems like the {} pairings provide enough information to tell where objects begin, end, and how they're nested... or?

4 Answers
Related