我有一個 json 陣列,我從中獲取我的反應資料,json 是這樣的:
{
"Folders": [
{
"name": "parent 2",
"children": [ //this is children_1
{
"name": "parent 2",
"id": "parent 2",
"children": [] //this is children_2
}
],
"id": 1
}
]
}
假設我在 children(children_1) 中有 name 的鍵值,我想使用我擁有的 name 獲取該 children 中的其余資料,有沒有辦法做到這一點?
uj5u.com熱心網友回復:
看jsonpath
所以它會
var json = require('jsonpath');
var names = jp.query(json, '$.Folders[*].children[*].children');
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/394930.html
標籤:javascript 数组 反应 json
