I am attempting to store a list of JSON Objects in an array using JavaScript. Below is the list:
[{"_id":1,"json":{"age":10,"name":"carlos"}},{"_id":2,"json":{"age":10,"name":"carlos"}}]
Here is the code snippet I have written:
var arrayResults = '{"files":' + '[{"_id":1,"json":{"age":10,"name":"carlos"}},{"_id":2,"json":{"age":10,"name":"carlos"}}]}';
alert (arrayResults.files.length);
var jsonData = JSON.parse(arrayResults);
for (var i = 0; i < arrayResults.files.length; i++) {
var file = jsonData.files.age[i];
alert(file);
}
Any assistance with this would be greatly appreciated. Thank you!