JSONPath examples for nested objects and arrays
JSONPath selects values from JSON by path. It is useful when you want the matching values and their provenance, not a transformed object or a computed summary.
JSON All-in-One evaluates JSONPath with an RFC 9535-oriented engine. That is important because examples copied from older or vendor-specific JSONPath dialects may not behave the same way.
Start with the source and exact matches
The fixture below has nested objects, arrays, missing members, a present null, and repeated property names. Each example names the expected result so you can tell whether a path is selecting what you intended.
A JSONPath query starts with $, the root value. The current value inside a filter is @.
{
"orders": [
{"id":"ord_1","status":"paid","total":129.5,"customer":{"name":"Lin","region":"EU"}},
{"id":"ord_2","status":"trial","total":0,"customer":{"name":"Mara","region":null}},
{"id":"ord_3","status":"paid","total":349,"customer":{"name":"Noor"}}
],
"meta": {"source":"sandbox"}
}$.orders[0].customer.nameChild, bracket, wildcard, index, and recursive syntax
Dot notation is concise for ordinary member names. Bracket notation is safer when a key contains punctuation, spaces, or characters that are awkward in dot notation. Wildcards select all children at that level.
Recursive descent with $..price-style patterns can be useful, but it searches broadly. On large documents, prefer a direct path when you know the containing branch.
| Need | JSONPath | Expected match |
|---|---|---|
| All order ids | $.orders[*].id | ord_1, ord_2, ord_3 |
| Second order | $.orders[1] | the trial order |
| All customer regions that exist | $.orders[*].customer.region | EU and null |
Any total member below root | $..total | 129.5, 0, 349 |
Filter arrays by record content
Filters run against array items. In $.orders[?@.status == "paid"], each order becomes @, and the expression keeps items whose status is paid.
Supported examples include comparison filters and RFC-style functions such as length, count, and match. Keep the query focused on the array branch you mean to inspect.
$.orders[?@.status == "paid"].total$.orders[?length(@.customer.name) == 3].idMissing, null, and multiple matches
A missing member produces no match for that path. A present null is a match whose value is null. Multiple array items can produce multiple matches, and duplicate selectors can preserve duplicate results in selector order.
That difference is why $.orders[*].customer.region returns two matches from the fixture: one string and one null. The third order has no region member, so it does not add a third value.
Why copied snippets fail
JSONPath has a long history of implementation-specific syntax. A query from another tool might rely on a legacy script expression, non-standard regex syntax, or a different interpretation of filters. In JSON All-in-One, write for the supported RFC 9535-style behavior and test the exact query.
If you are trying to build a new object, aggregate totals, or prepare rows for CSV, switch to JQ examples for filtering and transforming JSON. JSONPath selects; JQ transforms.
Troubleshooting
If the JSONPath input is unavailable, wait until the source has completed the stage required for JSONPath evaluation. If a path returns nothing, check whether the root is an object or array, whether the member is actually missing, and whether you accidentally pasted JQ syntax.
For large files, avoid starting with $..* or a broad recursive search. Prove the branch first, then make the query broader only if the narrower path misses valid data.