$.store.book[?(@.price < 10)].title

Here is a complete overview and a side by side comparison of the JSONPath syntax elements with its XPath counterparts.

XPath JSONPath Description
/ $ the root object/element
. @ the current object/element
/ . or [] child operator
.. n/a parent operator
// .. recursive descent. JSONPath borrows this syntax from E4X.

    • wildcard. All objects/elements regardless their names.
      @ n/a attribute access. JSON structures don't have attributes.
      [] [] subscript operator. XPath uses it to iterate over element collections and for predicates. In Javascript and JSON it is the native array operator.
      | [,] Union operator in XPath results in a combination of node sets. JSONPath allows alternate names or array indices as a set.
      n/a [start🔚step] array slice operator borrowed from ES4.
      [] ?() applies a filter (script) expression.
      n/a () script expression, using the underlying script engine.
      () n/a grouping in Xpath
posted on 2015-04-03 16:17  蚂蚁跳楼  阅读(383)  评论(0编辑  收藏  举报