I have JSON data that I am trying to store in a 2D array in the format:
[2009-01,324, 1075, 940, 441, 1040, 898, 1343]
[2009-02 295, 958, 904, 434, 1038, 793, 1246 ]
Apologies for the notation visual representation above. I have the JSON data and I am using a for loop to grab the key and its value but im not sure how to store this in a 2d array. I am struggling with this conceptually. Im a beginner and just really want some guidance with this. Thank you.
<script>
$.getJSON('data.json', function (data) {
var response = data;
var listOfTimes = new Array();
for(i = 0; i < 2; i++){ //number of rows...
for(j = 0; j< 8; j++){ //number of columns
for(key in response){
....not sure what to do here
}
}
}
});
</script>
The JSON data is in the format below:
"2009-01": {
"bbcfour": 324,
"bbcnews24": 1075,
"bbcone": 940,
"bbcthree": 441,
"bbctwo": 1040,
"cbbc": 898,
"cbeebies": 1343
},
"2009-02": {
"bbcfour": 295,
"bbcnews24": 958,
"bbcone": 904,
"bbcthree": 434,
"bbctwo": 1038,
"cbbc": 793,
"cbeebies": 1246
}