Jayway JsonPath is a Java port of [Stefan Goessner implementation](http://goessner.net/articles/JsonPath/). JsonPath expressions always refer to a JSON structure in the same way as XPath expression are used in combination
with an XML document. The "root member object" in JsonPath is always referred to as `$` regardless if it is an
| <ahref="http://jsonpath.herokuapp.com/?path=$.store.book[*].author"target="_blank">$.store.book[*].author</a>| The authors of all books |
| <ahref="http://jsonpath.herokuapp.com/?path=$..author"target="_blank">$..author</a> | All authors |
| <ahref="http://jsonpath.herokuapp.com/?path=$.store.*"target="_blank">$.store.*</a> | All things, both books and bicycles |
| <ahref="http://jsonpath.herokuapp.com/?path=$.store..price"target="_blank">$.store..price</a> | The price of everything |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[2]"target="_blank">$..book[2]</a> | The third book |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[(@.length-1)]"target="_blank">$..book[(@.length-1)]</a> | The last book |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[0,1]"target="_blank">$..book[0,1]</a> | The first two books |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[:2]"target="_blank">$..book[:2]</a> | All books from index 0 (inclusive) until index 2 (exclusive) |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[1:2]"target="_blank">$..book[1:2]</a> | All books from index 1 (inclusive) until index 2 (exclusive) |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[-2:]"target="_blank">$..book[-2:]</a> | Last two books |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[2:]"target="_blank">$..book[2:]</a> | Book number two from tail |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[?(@.isbn)]"target="_blank">$..book[?(@.isbn)]</a> | All books with an ISBN number |
| <ahref="http://jsonpath.herokuapp.com/?path=$.store.book[?(@.price < 10)]"target="_blank">$.store.book[?(@.price <10)]</a> | All books in store cheaper than 10 |
| <ahref="http://jsonpath.herokuapp.com/?path=$..book[?(@.price <= $['expensive'])]"target="_blank">$..book[?(@.price <= $['expensive'])]</a> | All books in store that are not "expensive" |
| <ahref="http://jsonpath.herokuapp.com/?path=$..*"target="_blank">$..*</a> | Give me every thing |
All `read` operations are overloaded and also supports compiled JsonPath objects. This can be useful from a performance perspective if the same path is to be executed
By default some simple object mapping is provided by the MappingProvider SPI. This allows to specify the return type you want and the MappingProvider will
try to perform the mapping. If a book, in the sample json above, had a long value 'published' you could perform object mapping between `Long` and `Date`
In the current implementation you can use `&&` to combine multiple predicates `[?(@.price < 10 && @.category == 'fiction')]`. OR operations are not supported yet.
###The Filter API
Predicates can be built using the Filter API as shown below:
Notice the placeholder `?` for the filter in the path. When multiple filters are provided they are applied in order where the number of placeholders must match
As specified in the Goessner implementation a JsonPath can return either `Path` or `Value`. `Value` is the default and what all the exaples above are reuturning. If you rather have the path of the elements our query is hitting this can be acheived with an option.
Changing the configuration defaults as demonstrated should only be done when your application is being initialized. Changes during runtime is strongly discouraged, especially in multi threaded applications.
Note that the JacksonJsonProvider requires `com.fasterxml.jackson.core:jackson-databind:2.4.1.3` and the GsonJsonProvider requires `com.google.code.gson:gson:2.3` on your classpath.