Cheatsheet: JsonPath

Last updated 2026-06-21

Objects and root

Select the root JSON value.

$

Select an object property with dot notation.

$.store

Select nested object properties.

$.address.city

Use bracket notation for property names with punctuation or spaces.

$['address']['postal-code']

Select multiple object properties at the same level.

$['firstName','lastName','email']

Arrays and wildcards

Select an array element by zero-based index.

$.carOptions[1]

Select the last array element using a negative index where supported.

$.items[-1]

Select all elements of an array with a wildcard.

$.items[*]

Select all property values of an object with a wildcard.

$.store.*

Select a half-open array slice from index 1 up to but not including 4.

$.items[1:4]

Select every second item from an array where slice steps are supported.

$.items[0:10:2]

Select multiple array indexes.

$.items[0,2,4]

Recursive descent and filters

Find every price property anywhere in the document.

$..price

Find all author properties under any book objects.

$.store..author

Filter array items by a numeric comparison.

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

Filter items that have an isbn property.

$.store.book[?(@.isbn)]

Filter with multiple conditions where supported by the implementation.

$.store.book[?(@.price < 10 && @.category == 'fiction')]

Filter using a regular expression where supported.

$.store.book[?(@.author =~ /.*Tolkien.*/)]

Functions and results

Get the length of a selected array where the implementation supports functions.

$.items.length()

Return the minimum price where aggregate functions are supported.

$..price.min()

Return the maximum price where aggregate functions are supported.

$..price.max()

Return the average price where aggregate functions are supported.

$..price.avg()

Return matching nodes and remember that exact function support varies between JSONPath libraries.

$..book[?(@.price)]

See also: