JSONPath cheat sheet
The everyday JSONPath selectors at a glance, over the bookstore. Press ▶ to run one.
The document the examples run on
{
"store": {
"book": [
{ "title": "Sayings of the Century", "author": "Nigel Rees",
"category": "reference", "price": 8.95 },
{ "title": "Sword of Honour", "author": "Evelyn Waugh",
"category": "fiction", "price": 12.99 },
{ "title": "Moby Dick", "author": "Herman Melville",
"category": "fiction", "price": 8.99, "isbn": "0-553-21311-3" },
{ "title": "The Lord of the Rings", "author": "J. R. R. Tolkien",
"category": "fiction", "price": 22.99, "isbn": "0-395-19395-8" }
],
"bicycle": { "color": "red", "price": 19.95 }
}
}| Query | What it does | Run it |
|---|---|---|
$ | the whole document | Try it |
$.store.bicycle.color | child segments | Try it |
$['store']['bicycle'] | bracket form | Try it |
$.store.book[0] | an array element | Try it |
$.store.book[-1] | the last element | Try it |
$.store.book[*].title | every element | Try it |
$.store.book[1:3] | a slice (end exclusive) | Try it |
$.store.book[0,2] | a union of indexes | Try it |
$.store.bicycle['color','price'] | a union of names | Try it |
$..price | descendants: at any depth | Try it |
$.store.book[[email protected] < 10] | a filter | Try it |
$.store.book[[email protected]] | an existence test | Try it |
$.store.book[[email protected] == 'fiction' && @.price < 13] | combined conditions | Try it |
$.store.book[?match(@.author, "^N")] | a function in a filter | Try it |