I get this JSON array via AJAX:
{
"success": 1,
"message": {
"ar": {
"total": 747.4851,
"list": [{
"total_statements": 1,
"total_due": 747.4851,
"name": "Paul McBilling",
"connection_id": 154
}]
},
"ap": {
"total": 0,
"list": []
},
"graphs": {
"graph": {
"2016-01": 13,
"2016-02": 0,
"2016-03": 0,
"2016-04": 747.4851,
"2016-05": 0,
"2016-06": 0,
"2016-07": 0,
"2016-08": 0,
"2016-09": 0,
"2016-10": 0,
"2016-11": 0,
"2016-12": 0
}
},
"cached": 1
}
}
And the result I would like to get back would look something like this (in the console):
2016-01: 13
2016-02: 0
...
And I'm trying to log each key and value pair of the inner "graph" array.
I've tried this:
$(data.message.graphs.graph).each(function(key, value){
console.log(key +' and '+ value);
});
But what this returns is only once:
0 and [object Object]