Recently, I've been working with an array printed in JSON format.
[{"Name":"John Ranniel","Age":"19","City":"Manila"},{"Contact":"09197875656","Relation":"Sister"}]
Unexpectedly, I had to split the JSON array into two parts for some reason.
When decoding the JSON using JSON.parse()
in JavaScript:
For instance:
var arr = JSON.parse(response); // The response variable holds the given JSON above
alert(arr[0].Name) // It still displays John Ranniel. However, if I modify the alert box content to reference the second part of the JSON,
alert(arr[1].Contact) // There is no output. I'm unsure whether there's an issue with the array index.