What I mean by that is say I have JSON data as such:
[{"ADAM":{"TEST":1}, "BOBBY":{"TEST":2}}]
and I want to do something like this:
var x = "ADAM";
alert(data.x.TEST);
What I mean by that is say I have JSON data as such:
and I want to do something like this:
|
|||
|
|
|||
|
Since objects in javascripts are handled just like hashmaps (or associative arrays) you can just do data['adam'].TEST just like you could do data.adam.TEST. If you have a variable index, just go with the [] notation.
if you just do
you could access it using data.ADAM.TEST and data['ADAM'].TEST |
|||
|
That won't work as you're setting
|
|||
|