Possible Duplicate:
Parsing JSON with JavaScript
I understand to get the value of a json data, for instance var json = [{"country":"US"}]
, I can do it like json[0].country
.
I've this json data [{"0":"US"}]
, so how do I retrieve the data then?
I understand to get the value of a json data, for instance I've this json data
| |||
feedback
|
This question covers exactly the same content as earlier questions on this topic; its answers may be merged with another identical question. See the FAQ for guidance on how to improve it.
You could use | |||||
feedback
|
If I'm understanding your question correctly, it would just be
to retrieve your data. The zero is in quotes the second time round, because it's stored as a string in your example. | |||
feedback
|
Here the key of the only object into the array is string so you can access it with:
| |||
feedback
|
var myvar = { mykey: myvalue }
you can domyvar[mykey]
. You can event execute functionsvar myvar = { mykey: function(){...} }
withmyvar[mykey]()
. – Didier Ghys Dec 21 '11 at 9:34myvar["mykey"]
. – Edgar Bonet Dec 21 '11 at 11:53