After using php's json_encode() function, I received a string that looks like this:
[ { "key1":"value1",
"key2":"value2",
"key3":"value3"
},
{ "key1":"value1",
"key2":"value2",
"key3":"value3"
} ]
To convert the string into a Javascript object, I utilized the JSON.parse function in Javascript:
var jsonObj=JSON.parse(string);
The challenge now is how to access the data inside the inner objects that have no names. I attempted to do so with the following code:
alert(jsonObj.firstChild.key1);
However, it returns "undefined". Can anyone explain why?