Learn

What is JSONPath?

Direct answer: JSONPath is a query language for selecting and extracting values from JSON documents, similar to how XPath works for XML. Expressions typically start with $ (the root) and use dots, brackets, and wildcards to navigate nested fields.

Step-by-step

  1. Step 1

    Start at the root

    Use $ to refer to the entire document.

  2. Step 2

    Walk properties

    Use .field or ['field'] to descend into objects.

  3. Step 3

    Select arrays

    Use [0], [*], or [?(@.price<10)] style filters depending on your engine.

Examples

Select all author names

$.store.book[*].author

First item SKU

$.data.items[0].sku

Nested preference

$.user.profile.preferences.theme

FAQ

Is JSONPath standardized?

Implementations vary. Stick to widely supported features (root, property access, array indexes, wildcards) for portability.

JSONPath vs jq?

JSONPath focuses on selection. jq is a full programming language for transforming JSON streams.

Try it in BracketView