I want to have a JSON object which contains multiple person objects. Is there a better way to format this? What I did below is have a result key which would be an array consisting of arrays (which have the JSON person object inside of the inner array).
{
result: [
[
{
"name": "Josh",
"age": 15
}
],
[
{
"name": "Joe",
"age": 16
}
]
]
}
Then in the for loop I do something like this:
var nameArray = result[0];
for (var i = 0; i < numberOfObjectsInJSONObject; i++) {
newNameArray.push(nameArray[i].firstPerson);
}
resultcould be a simple array of objects (p.s. these are objects, not JSON. JSON may be how you retrieve the data, but this isn't JSON you are working with)