(对不起,如果标题没有多大意义,我无法弄清楚如何正确地说出来)
因此,我尝试从API获取响应,但API会返回多个具有相同名称的响应。 回复之前:
{
"xuid": 2535436668322645,
"state": "Online",
"devices": [
{
"type": "XboxOne",
"titles": [
{
"id": 714681658,
"name": "Home",
"placement": "Background",
"state": "Active",
"lastModified": "2016-11-22T23:45:08.8296994Z"
},
{
"id": 74304278,
"activity": {
"richPresence": "Lvl 30 in Hudson Yards"
},
"name": "Tom Clancy's The Division",
"placement": "Full",
"state": "Active",
"lastModified": "2016-11-22T23:45:08.8296994Z"
}
]
}
]
}
所以我想知道,我怎样才能从"第二个"使用JavaScript响应? (那个说#34;汤姆克兰西的分部"名字部分)谢谢!
答案 0 :(得分:-1)
这应该让你走上正确的轨道(未经测试)
var obj = jQuery.parseJSON(YOUR_JSON);
obj->devices[0]->titles[1]->id // second id