Where row is the variable holding property name not the object, so you need to retrieve it using the property name ( Refer : for...in loop documentation). In your case it will be the index of array. There is no need to use for...in iterator here, a simple for loop is enough.
for (var row in json.rows) {
console.log(json.rows[row].key);
}
var json = {
"rows": [{
"key": "value"
}, {
"key": "value"
}]
};
for (var row in json.rows) {
console.log(json.rows[row].key);
}
With a simple for loop
for (var i=0;i < json.rows.length; i++) {
console.log(json.rows[i].key);
}
var json = {
"rows": [{
"key": "value"
}, {
"key": "value"
}]
};
for (var i = 0; i < json.rows.length; i++) {
console.log(json.rows[i].key);
}
Since the property holds an array useArray#forEach method to iterate.
json.rows.forEach(function(v){
console.log(v.key);
}
var json = {
"rows": [{
"key": "value"
}, {
"key": "value"
}]
};
json.rows.forEach(function(v) {
console.log(v.key);
})