JSONPath examples for nested JSON and arrays
Practical JSONPath expressions for finding nested fields, array items, and values in API responses and configuration data.
Use the root symbol
JSONPath expressions usually start with $ for the root document. Dot notation selects a property, while bracket notation is useful when a property name contains characters that dot notation cannot represent.
For example, $.user.name selects the name inside a top-level user object. Keep expressions short and test them against the exact JSON shape you receive.
$.user.name
$.settings["feature-flag"]Select array values
Use [*] to examine a property on every array item. For example, $.items[*].id selects id from each object in an items array. Use an explicit index such as $.items[0] when you need a known position.
An empty result often means the property is nested differently, the field name has different casing, or the value is not an array.
$.items[*].name
$.items[0].priceUse JSONPath for inspection, not validation
JSONPath answers which values match an expression. It does not define whether an entire document is valid. Pair it with JSON Schema when you need a reusable contract for incoming data.