当在复杂的JSON数组和散列中搜索项时,比如:
[
{ "id": 1, "name": "One", "objects": [
{ "id": 1, "name": "Response 1", "objects": [
// etc.
}]
}
]
是否有某种查询语言,我可以用来在[0]中找到一个项目。id = 3的对象?
当在复杂的JSON数组和散列中搜索项时,比如:
[
{ "id": 1, "name": "One", "objects": [
{ "id": 1, "name": "Response 1", "objects": [
// etc.
}]
}
]
是否有某种查询语言,我可以用来在[0]中找到一个项目。id = 3的对象?
当前回答
索纳塔 https://jsonata.org/
它有一个操场,你可以下载图书馆
其他回答
索纳塔 https://jsonata.org/
它有一个操场,你可以下载图书馆
JMESPath现在似乎非常流行(截至2020年),并解决了JSONPath的许多问题。它适用于许多语言。
我知道的其他选择是
JSONiq specification, which specifies two subtypes of languages: one that hides XML details and provides JS-like syntax, and one that enriches XQuery syntax with JSON constructors and such. Zorba implements JSONiq. Corona, which builds on top of MarkLogic provides a REST interface for storing, managing, and searching XML, JSON, Text and Binary content. MarkLogic 6 and later provide a similar REST interface as Corona out of the box. MarkLogic 8 and later support JSON natively in both their XQuery and Server-side JavaScript environment. You can apply XPath on it.
HTH.
为了增加更多的选择,还有XPath。XPath 3.1处理JSON和XML。在XPath 3.1中,您需要的查询是?0?Objects?*[?id = 3)
试试这个——https://github.com/satyapaul/jpath/blob/master/JSONDataReader.java
这是一个非常简单的实现,类似于xpath for xml。它的名称是jpath。