Yes, there are many posts about this. But my doubts are not much different. I have the following array for example
var dictionary = { "12Jan2013": [{ "id": "0", "name": "ABC" }, { "id": "1", "name": "DEF" }], "13Jan2013": [{ "id": "0", "name": "PQR" }, { "id": "1", "name": "xyz" }] };
The same message is on the same site , but here, in the json dictionary, the key array is dynamic . Here is the date, i.e. 12Jan2013.This can be any date. It is not static. I searched for this, but got no solution.
How to iterate over such a json array?
And how to print a json array, as in the same formation as shown above?
EDIT
Here is my real code. And I showed a comment in the following code where I wanted to iterate data, i.e. jsonData var in getWeatherDataForCities callback
var arrAllrecords = []; var arrCityrecordForADay = []; function getWeatherDataForCities(cityArray, callback){ var toDaysTimestamp = Math.round((new Date()).getTime() / 1000) - (24*60*60); for(var i in cityArray){ for(var j=1; j<=1; j++){ var jsonurl = "http://api.openweathermap.org/data/2.5/history/city?q="+cityArray[i]+"&dt="+toDaysTimestamp; $.ajax({ url: jsonurl, dataType: "jsonp", mimeType: "textPlain", crossDomain: true, contentType: "application/json; charset=utf-8", success: function(data){ var arrCityRecordForDay = [];
json javascript iteration
Prashant shilimkar
source share