I have this json array:
var a = [{"results":[{"id":"25","name":"John","age":"46"},{"id":"41","name":"Sonny","age":"31"}],"count":2,"total":14}];
It contains an array called “results” and two other variables with numerical values, count and total.
How can i get each of the values of “results”, “count” and “total” from the above array ?
I tried: console.log(a.count);
But it says undefined.
First, execute your code will cause
SyntaxError: Unexpected token ILLEGAL.There is an invalid character after
agebetween"age":"31".Remove that, then
ais an array, so you get the first element bya[0],then
get the count by
a[0].countget the results by
a[0].results