title: How to iterate over json array in javascript
body: <p>Yes there are many post regarding this.But my doubt is little different.I have following array for example</p>
  
  <pre><code>var dictionary = {
      "12Jan2013": [{
          "id": "0",
          "name": "ABC"
      }, {
          "id": "1",
          "name": "DEF"
      }],
      "13Jan2013": [{
          "id": "0",
          "name": "PQR"
      }, {
          "id": "1",
          "name": "xyz"
      }]
  };
  </code></pre>
  
  <p>Same post is there on same site <strong>BUT here in dictionary <code>json</code> array key is dynamic</strong>.Here it is date ie 12Jan2013.It can be any date.It is not static.I have searched for that but didn't get solution.</p>
  
  <p><strong>How to iterate over such a json array?</strong></p>
  
  <p><strong>AND How to print json array as in same formate shown above?</strong></p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Here is my real code.And <strong>i shown a comment in following code</strong> where i wanted to <code>iterate</code> data ie <code>jsonData</code> var in <code>getWeatherDataForCities</code> callback</p>
  
  <pre><code>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&lt;=1; j++){
          var jsonurl = "http://api.openweathermap.org/data/2.5/history/city?q="+cityArray[i]+"&amp;dt="+toDaysTimestamp;
  
          $.ajax({
              url: jsonurl,
              dataType: "jsonp",
              mimeType: "textPlain",
              crossDomain: true,
              contentType: "application/json; charset=utf-8",
              success: function(data){                    
                  var arrCityRecordForDay = [];
                  /*arrCityrecordForADay.push(data.list[0].city.name);
                  arrCityrecordForADay.push(data.list[0].weather[0].description);
                  arrCityrecordForADay.push(timeConverter(data.list[0].dt));
                  arrCityrecordForADay.push(data.list[0].main.temp);
                  arrCityrecordForADay.push(data.list[0].main.humidity);
                  arrCityrecordForADay.push(data.list[0].main.pressure)
                  arrCityrecordForADay.push(data.list[0].wind.speed);*/
                  //'{"pets":[{"name":"jack"},{"name":"john"},{"name":"joe"}]}';
  
                  arrCityRecordForDay.push(
                      {"cityName" : data.list[0].city.name},
                      {"weather" : data.list[0].weather[0].description}
                  );
  
                  var tempId = data.list[0].city.name+"-"+timeConverter(data.list[0].dt);
  
                  arrCityrecordForADay.push(
                      {tempId : arrCityRecordForDay}
                  );
  
                  if(((arrCityrecordForADay.length)) === cityArray.length) {
                      callback(arrCityrecordForADay);
                  }
  
          } });
          toDaysTimestamp = toDaysTimestamp - (24*60*60);
      }   
  }       
  }
  
  $(document ).ready(function() {
  
   var cityArray = new Array();
    cityArray[0] = "pune";
  
    getWeatherDataForCities(cityArray, function(jsonData) {
          // Here I want to iterate jsonData
    });
  
  
  });
  </code></pre>