gpt4 book ai didi

javascript - 遍历json节点

转载 作者:行者123 更新时间:2023-12-02 19:32:59 25 4
gpt4 key购买 nike

是否可以遍历所有节点,从一个级别未预先确定的复杂json中找到想要的字段

{
"_index": "test",
"_type": "news",
"_source": {
"partnerName": "propertyFile 9",
"relatedSources": "null",
"entityCount": "50",
"Categories": {
"Types": {
"Events": [{
"count": 1,
"term": "Time",
"Time": [{
"term": "Dec 9",
"Dec_9": [{
"count": 1,
"term": "2012"
}]
}]
}, {
"count": 4,
"term": "News",
"News": [{
"term": "Germany",
"Germany": [{
"count": 1,
"term": "Election"
}],
"currency": "Euro (EUR)"
}, {
"term": "Egypt",
"Egypt": [{
"count": 1,
"term": "Revolution"
}]
}]
}]
}
}
}
}

我可以进入第一级,但是如果第一级中不存在字段名称,我如何进入第二级。我就是这样开始的。 http://jsfiddle.net/W8qhA/1/

最佳答案

希望这能解决您的问题。有一些功能,也有一些解释。希望对您有所帮助。 Traverse all the Nodes of a JSON Object Tree with JavaScript

关于javascript - 遍历json节点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11288210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com