JSON GUIDE · 4 MIN READ

A practical JSONPath guide

Select nested fields and array items, then distinguish JSONPath from JSON Pointer and JMESPath.

Start with a small selection

Use $ for the root, a property selector to navigate objects, and an index or wildcard to inspect arrays. For the example below, $.people[0].name selects Ada, while $.people[*].name selects the names of every person. Bracket notation such as $['people'] is helpful when names contain punctuation.

A query can return several matches or none. Inspect both values and paths so that two equal values in different branches do not look like the same match. A missing match is different from a selected null.

{"people":[{"name":"Ada","score":12},{"name":"Lin","score":9}]}

Use the right language for the task

JSON Pointer identifies one exact location and has an escaping convention for slash and tilde. JMESPath is useful when you want a projection, filter, or computed shape. Their expressions are not interchangeable with JSONPath.

JSONPath implementations vary, even with a published standard. JSONSlate disables JavaScript evaluation in its JSONPath engine; expressions requiring script execution are rejected. Use the separate JMESPath tool for supported filters and never treat an untrusted expression as executable JavaScript.

Put it into practice

Further reading

← All JSON guides