0
我想要檢索JavaScript對象的一部分。如何從javascript中的對象檢索特定的字段?
最終的對象應該具有的所有hits.hits._source 我嘗試不同的事情lodash或下劃線,但我沒有得到它
我inital對象是
{
"took": 7,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3,
"max_score": 1,
"hits": [
{
"_index": "users",
"_type": "user",
"_id": "1",
"_score": 1,
"_source": {
"id": "112",
"type": "pro",
"email": "[email protected]"
}
},
{
"_index": "users",
"_type": "user",
"_id": "2",
"_score": 1,
"_source": {
"id": "2",
"type": "pro",
"email": "[email protected]"
}
}
]
}
}
我想獲得
[
{
"id": "112",
"type": "pro",
"email": "[email protected]"
},
{
"id": "2",
"type": "pro",
"email": "[email protected]"
}
]
啃削從root.hits.hits 「_source」 – dandavis 2015-02-23 08:25:51
'B = [];對於(i的a.hits.hits){b.push(a.hits .hits [i] ._ source)}''會得到'b'作爲你的答案 – itzMEonTV 2015-02-23 08:29:55