我需要幫助來訪問位於我的JSON數據集的嵌套數組。這裏是我的頂級JSON數組的第一個條目:如何在JSON數據中引用嵌套數組?
{
"pingFeed": [{
"header": "Get Drinks?",
"picture": "images/joe.jpg",
"location": "Tartine's, SF",
"time": "Tomorrow Night",
"name": "Joe Shmoe",
"pid":
"123441121",
"description": "Let's drop some bills, yal!",
"comments": [{
"author": "Joe S.",
"text": "I'm Thirsty"
},
{
"author": "Adder K.",
"text":
"Uber Narfle"
},
{
"author": "Sargon G.",
"text": "taeber"
},
{
"author": "Randy T.",
"text": "Powdered Sugar"
},
{
"author": "Salvatore D.",
"text":
"Chocolate with Sprinkles"
},
{
"author": "Jeff T.",
"type": "Chocolate"
},
{
"author": "Chris M.",
"text": "Maple"
}],
"joined": false,
"participants": [
"Salvatore G.", "Adder K.", "Boutros G."],
"lat": 37.25,
"long": 122,
"private": true
}]
}
我想知道我可以使用下面的符號訪問的意見和參與者的數據:
for (var k = 0; k < pingFeed.length ; k++) {
console.log(pingFeed[k].comments);
console.log(pingFeed[k].participants);
}
目前這種形式的點符號正在爲JSON數組中的其他條目工作... 我期待將所有這些數據作爲字符串返回。
Tartine是一個偉大的資源taurant,抱歉,我無法抗拒。 – 2010-09-13 23:05:27
我只有他們的蛋糕。 – Sachin 2010-09-13 23:40:28