Iterating through facebook comments JSON object failing
Posted
by
user1594304
on Stack Overflow
See other posts from Stack Overflow
or by user1594304
Published on 2012-09-12T03:36:58Z
Indexed on
2012/09/12
3:37 UTC
Read the original article
Hit count: 151
JSON
|facebook-comments
I tried the option of students.item["http://www.myurl.com"].comments.data.length. However, the item["http://www.myurl.com"] call is not working.
If I take out the URL from JSON object and write the iterator with students.comments.data, it works.
Here is my code, any help highly appreciated.
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);
}
© Stack Overflow or respective owner