2014-02-28 76 views
0

JSONPath queries有什麼可能性。以下是我從 JSONPath - XPath for JSONJSON路徑查詢的可能性

$.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這些不工作的查詢,所以我想知道什麼是正確的可能性。

回答

0

JSONPath不是一種標準化的查詢語言(也沒有完全實現) - XPath是。

使用DefiantJS(http:/defiantjs.com/),您可以使用XPath表達式查詢JSON結構。要看到它的實際操作,請查看實時XPath評估程序:

http://defiantjs.com/#xpath_evaluator