I'm dealing with a fairly complex JSON array, included below. I'm trying to create an array of the Country objects with their included visits. Heres a sample of the array:
{
"data":[
{
"period":"Month",
"start_date":"2012-06",
"end_date":"2012-07",
"attributes":{
},
"measures":{
"Visits":1000000
},
"SubRows":[
{
"Unknown":{
"measures":{
"Visits":1000
},
"SubRows":null
},
"**":{
"measures":{
"Visits":1000
},
"SubRows":null
},
"Afghanistan":{
"measures":{
"Visits":1000
},
"SubRows":null
},
"Aland Islands":{
"measures":{
"Visits":1000
},
"SubRows":null
},
"Albania":{
"measures":{
"Visits":100
},
"SubRows":null
},
}
]
}
]
}
I'm using data[0].SubRows[0]
to get down to an array of the country objects, but now I'm stumped how to go one below as each sub object is named differently? My intended output is for the Google Visualisation API, as follows:
var data = google.visualization.arrayToDataTable([
['Country', '% Visits'],
['United Kingdom', 1000],
['United States', 1000],
['France', 1000],
['Australia', 1000],
]);