我想吐出全部來自一個JSON塊的用戶場景,但我失去了一些東西......循環相同的密鑰JSON節點
你想看看?
我把它放在這裏也: http://jsfiddle.net/RBergante/2HwEH/
這是我有:
function scenes(){
var allscenes = new Array();
for (var i in data.users){
allscenes = data.users[i].scenes.scene;
document.write(allscenes[i] + "</br>");
}
}
var data={"users":[
{
"firstName":"Rick",
"lastName":"Villalobos",
"pic":"http://ia.media-imdb.com/images/M/[email protected]@._V1._SY209_CR1,0,140,209_.jpg",
"scenes": {
"scene": "In the Woods",
"scene": "City lights",
"scene": "Marnon Willis"
},
"joined": {
"month":"January",
"day":12,
"year":2012
}
},
{
"firstName":"John",
"lastName":"Jones",
"pic":"http://ia.media-imdb.com/images/M/[email protected]@._V1._SY209_CR0,0,140,209_.jpg",
"joined": {
"month":"April",
"day":28,
"year":2010
}
}
]}
scenes();
謝謝!
「約翰」沒有任何場景; Uncaught TypeError:無法讀取未定義的屬性「場景」 – Stefan 2013-02-20 11:51:14