PDA

View Full Version : Reading JSON



mackenda
24 Sep 2009, 7:54 AM
I have a Json Object with the following Data

{'total':'21','data':[{'Rank':'1','IMSI':'321566698754','Failures':'3','Successes':'4'},{'Rank':'2','IMSI':'331566698754','Failures':'2','Successes':'1'},{'Rank':'21','IMSI':'1982475223','Failures':'1','Successes':'60'}]}

After I use

var jsonData = Ext.util.JSON.decode(result.responseText);

to get the json object into a Javascript object how can I reference the Total and the Data?????

24 Sep 2009, 11:30 AM
JSON stands for "JavaScript Object Notation".

Meaning, it's a Plain 'ol object!
paste the following infirebug:

var data = "{'total':'21','data':[{'Rank':'1','IMSI':'321566698754','Failures':'3','Successes':'4'},{'Rank':'2','IMSI':'331566698754','Failures':'2','Successes':'1'},{'Rank':'21','IMSI':'1982475223','Failures':'1','Successes':'60'}]}";

var jsonData = Ext.decode(data);
console.log(jsonData.total);
console.info(jsonData.data);