JSON路径查询可能性

时间:2014-02-28 08:45:55

标签: json jsonpath

JSONPath queries的可能性有多大。以下是我在 JSONPath - XPath for JSON

中找到的查询
$.store.book[*].author
$..author
$.store.*
$.store..price
$..book[2]
$..book[(@.length-1)]
$..book[-1:]
$..book[0,1]
$..book[:2]
$..book[?(@.isbn)]
$..book[?(@.price<10)]
$..*

JSONPath

期间跟随也可能的查询有效
$.data2.passes[0].id
$.store.bicycle.['dot.notation']
$.['store'].bicycle.['dot.notation']
$['store']['bicycle']['dot.notation']
$.['store']['bicycle']['dot.notation']
$.['store'].['bicycle'].['dot.notation']   
$.['store'].bicycle.['dash-notation']
$['store']['bicycle']['dash-notation']
$.['store']['bicycle']['dash-notation']
$.['store'].['bicycle'].['dash-notation']    
$.store.bicycle.foo:bar"
$['store']['bicycle']['foo:bar']
$.store
$.store.book[1]    
$.store.book[*]    
$.store.book[0,1]    
$.store.book[0,1].author
$.store.book[*].author    
$.['store'].['book'][*].['author']
$['store']['book'][*]['author']
$['store'].book[*]['author']    
$..author    
$.store.*    
$.[0].[0].author    
$.[0][0].author    
$.store..['display-price']

当我使用在线评估者JSONPath Online Evaluator尝试这些查询时,这些不起作用,所以我想知道什么是正确的可能性。

1 个答案:

答案 0 :(得分:0)

JSONPath不是标准化的查询语言(也没有完全实现) - XPath是。

使用DefiantJS(http:/defiantjs.com/),您可以使用XPath表达式查询JSON结构。要查看它的实际效果,请查看实时XPath评估器:

http://defiantjs.com/#xpath_evaluator