I know this is a simple question, but I can't access the data in my json object. It looks like this:
var string={"data":
[
{
"city": "Gansu",
"value": "#000"
},
{
"city": "Ningzhau",
"value": "#000"
},
{
"city": "Chongqing",
"value": "#000"
}
]
};
var obj =JSON.parse(string);
To test it, I am doing: document.write(obj.data[0].city);
which I think should return Gansu.
Can someone tell me what is wrong with the last line of code and how to fix it? Thanks.