我用了
console.log(response);
并在控制台(在 Firebug 中)中得到以下信息。如何循环检查“LMNOPQ”是否存在?
data [Object { name="Excel in ABCD", category="Book", id="327361517327399", more...}, Object { name="LMNOPQ", category="Product/service", id="175625882542984", more...}, Object { name="UVWXYZ", category="Book", id="260641707360118", more...}, 7 more...]
0 Object { name="Excel in ABCD", category="Book", id="327361517327399", more...}
category "Book"
created_time "2012-04-04T05:31:04+0000"
id "327361517327399"
name "Excel in ABCD"
1 Object { name="LMNOPQ", category="Product/service", id="175625882542984", more...}
2
Object { name="UVWXYZ", category="Book", id="260641707360118", more...}
然后按照 Baptiste Pernet 的建议,我尝试了以下方法:
for(var i in response) {
console.log(response[i].name);//gives me undefined
console.log(response[i]);//gives me another object (it is nested, check below)
}
[Object { name="Excel in ABCD", category="Book", id="327361517327399", 更多...}, Object { name="LMNOPQ", category="Product/service", id="175625882542984" , 更多...}, 对象 { name="UVWXYZ", category="Book", id="260641707360118", 更多...},
我现在如何获得这个名字?我被困在:
console.log(response[i]);
为了获得嵌套对象的属性,我应该写什么?另一个循环?