I've figured how to iterate through the following JSON as seen here:
{"dummmysetsJSONArr":[{"entryID":"1","distance":"100","calories":"50"},{"entryID":"2","distance":"200","calories":"100"},{"entryID":"3","distance":"300","calories":"150"},{"entryID":"4","distance":"400","calories":"200"},{"entryID":"5","distance":"500","calories":"250"},{"entryID":"6","distance":"600","calories":"300"}],"success":1}
Here's how I do this:
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
myLogger(jsonarray[key].entryID + " - " + jsonarray[key].distance + " - " + jsonarray[key].calories);
}
}
But the JSON is failing the if check in the for loop.
What could be wrong with my JSON data?
My objective is to use the above for loop to add data to google.visualization.DataTable() as follows:
data = new google.visualization.DataTable();
data.addColumn('number', 'distance');
data.addColumn('number', 'calories');
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
//data.addRow(jsonarray[key].distance);
//data.addRow(jsonarray[key].calories);
}
}