Reputation: 553
I have an json Object like this.
{'01/19/2012': Array[1],'02/19/2012': Array[7],'03/19/2012': Array[6]}
Now i want to iterate this map
I need result like
Date : 01/19/2012
Array Data here
Date : 02/19/2012
Array Data here
Thanks!!
Upvotes: 3
Views: 18739
Reputation: 21820
Use a for loop in which you use condition: "var x in y" where y is the object.
for (var key in p) {
if (p.hasOwnProperty(key)) {
alert(key + " -> " + p[key]);
}
}
https://stackoverflow.com/a/684692/680578
Upvotes: 12
Reputation: 755
Use a "for ... in" loop.
http://www.w3schools.com/js/js_loop_for_in.asp
If you need to sort the data (as you might with dates), use "for ... in" to push the elements into an Array, use sort(), and then process the results.
More on sort(): http://www.w3schools.com/jsref/jsref_sort.asp
Upvotes: -1