JSONPath
JSONPath quick reference for root paths, property selectors, array indexes, wildcards, recursive descent, unions, and slices supported by the OCMA tester.
A JSONPath query starts at $ and selects properties or array elements. This sheet documents the subset evaluated by the OCMA JSONPath Tester. It is not a complete list of operators in the JSONPath standard (RFC 9535).
Sample document
Use this object to check each expression and its result below.
{
"store": {
"book": [
{ "title": "Sayings of the Century", "author": "Nigel Rees", "price": 8.95 },
{ "title": "Sword of Honour", "author": "Evelyn Waugh", "price": 12.99 },
{ "title": "The Lord of the Rings", "author": "J.R.R. Tolkien", "price": 22.99 }
],
"bicycle": { "color": "red", "price": 19.95 }
}
}Build a path from the root
| Expression | Result | What it selects |
|---|---|---|
$ | The whole document | Root object or array |
$.store | { "book": […], "bicycle": {…} } | Property store at the root |
$.store.book | The array of books | A nested object property |
$.store.book[0].title | ["Sayings of the Century"] | Property of the first array item |
$.store['book'] | The array of books | Quoted-key form for an object property |
Dot notation is concise for simple names. Use brackets for array indexes or keys that need quoting.
Array selectors
| Expression | Result for the sample | Behavior |
|---|---|---|
$.store.book[0] | First book | Indexes start at zero |
$.store.book[-1].title | ["The Lord of the Rings"] | Negative index counts back from the end |
$.store.book[*].author | ["Nigel Rees", "Evelyn Waugh", "J.R.R. Tolkien"] | Wildcard selects every array item |
$.store.book[0,2].title | ["Sayings of the Century", "The Lord of the Rings"] | Union of numeric indexes |
$.store.book[1:3].title | ["Sword of Honour", "The Lord of the Rings"] | Start included; end excluded |
$.store.book[0:3:2].title | ["Sayings of the Century", "The Lord of the Rings"] | Positive step skips items |
Wildcards & recursive descent
$.store.book[*].price[8.95, 12.99, 22.99]
Wildcard over the book array, then select each price.
$.store.*The book array and bicycle object
Wildcard over the immediate values of the store object.
$..price[8.95, 12.99, 22.99, 19.95]
Find every price property, including the nested bicycle price.
$..author["Nigel Rees", "Evelyn Waugh", "J.R.R. Tolkien"]
Find author properties without naming the store.book path.
Recursive descent searches descendants at any depth. If the same property name occurs in more than one branch, expect more than one result; use a longer path to narrow the selection.
Result and error checks
| What you see | Check |
|---|---|
| JSON parse error | Fix the input first: JSON requires quoted property names and does not allow trailing commas. |
[] with no matches | Check spelling, capitalization, whether a value is an object or array, and whether the operator is supported. |
| Several values returned | A wildcard or recursive descent may be selecting more branches than intended. |
| Unexpected single result shape | Matches are always presented as a JSON array, even when there is only one value. |
For a worked explanation of each selector, read JSONPath Queries: Select Values from Nested JSON.