我尝试了students.item [“http://www.myurl.com”] .comments.data.length的选项。但是,该项目[“http://www.myurl.com”]呼叫不起作用。通过Facebook评论迭代JSON对象失败
如果我从JSON对象中取出URL并使用students.comments.data编写迭代器,它将起作用。
这是我的代码,任何帮助高度赞赏。
var students = {
"http://www.myurl.com":{
"comments":{
"data" : [{
"id": "123456778",
"from": {
"name": "XYZ",
"id": "1000005"
},
"message": "Hey",
"can_remove": false,
"created_time": "2012-09-03T03:16:01+0000",
"like_count": 0,
"user_likes": false
}]
}
}
}
var i=0
var arrayObject = new Array();
alert("Parsing 2: "+students.item["http://www.myurl.com"].comments.data.length);
for(i=0;i<students.item["http://www.myurl.com"].comments.data.length;i++)
{
alert("Parsing 1: "+i);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].id);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].message);
arrayObject.push(students.item["http://www.myurl.com"].comments.data[i].created_time);
}
.item从哪里来?这似乎是不必要的 – endyourif