I want to iterate through a json object which is two dimensional ...
for a one dimensional json object I do this
for (key in data) {
alert(data[key]);
}
what do i do about a two dimensional one??
Answer
There is no two dimensional data in Javascript, so what you have is nested objects, or a jagged array (array of arrays), or a combination (object with array properties, or array of objects). Just loop through the sub-items:
for (var key in data) {
var item = data[key];
for (var key2 in item) {
alert(item[key2]);
}
}
No comments:
Post a Comment