Access JSON Object in array -
hi i'm trying charting google analytics , can data json stuck there, json seen in firebug.
{"total_results":1,"rows":[[7861]],"column_headers":[{"datatype":"integer","columntype":"metric","name":"ga:visits"}]}
so i'm trying extract fact gavisits has 7842 results last 30 days, code
$.getjson( "https://api.oocharts.com/v1/query.jsonp?" //note 'jsonp' return type + "query=" + "visits-by-date-cg" + "&key=" + "myapikey here" + "&start=" + "30d" //30 days current date + "&callback=?" , null, function(data) { console.log(json.stringify(data)); });
how loop through 'data' 7842 can store variable?
thank you
you won't find 7842
anywhere in object, there property called rows
containing array 1 value, array 1 value, 7861
. that's you're looking for:
data.rows[0][0]
Comments
Post a Comment