Can a JSON array contain objects of different key/value pairs?

You can use any structure you like. JSON is not schema based in the way XML is often used and Javascript is not statically typed.

you can convert your JSON to a JS object using JSON.parse and then just test the existence of the property

var obj = JSON.parse(jsonString);
if(typeof obj.example[0].firstName != "undefined") {
   //do something
}

Leave a Comment