-1
可能重複:
I have a nested data structure/JSON, how can I access a specific value?如何訪問此javascript對象的屬性?
var response =
{
"members": [{
"hello": "goodbye",
"foo": "bar"
}],
"tags": {
"1065677": [{
"tag_id": "244223",
"tag_name": "lol-wat",
"user_id": "1065677"
}],
"1065678": [{
"tag_id": "244224",
"tag_name": "baby",
"user_id": "1065678"
}]
}
}
本工程以傾倒整個對象:
console.log(response.tags[1065678]);
我現在希望得到一個特定值的關鍵,即baby
:
console.log(response.tags[1065678].tag_name);
console.log(response.tags[1065678]['tag_name']);
以上都沒有工作,爲什麼?