Been searching for an hour or o and can't find what I'm looking for. Any help appreciated.
I have a JSON object coming from an ajax call that contains a couple of other objects with numerical keys.
Eg.
{"1" : { "Name" : "George", "DOB" : "11/1/88", "NickName" : "Porky" },
"2" : { "Name" : "Pete", "DOB" : "6/6/85", "NickName" : "Bozo" }}
I now want to access the properties in these object independently. For example:
for(var key in obj) {
alert(obj. something here .Name);
}
But I can't for the life of me find the right syntax. I have tried...
obj.1.Name (I've seen this where the key of each object is a string but not a number)
and...
obj[1].Name
Can someone please put me out of my misery? How can I say, create an array of [Name1, Name2, etc...]
?