Skip to content

JSONPath, Minus the Headache: How to Find Any Value in a JSON Response

Published · Updated

JSONPath is a query syntax for selecting values from JSON. RFC 9535 is now the IETF standard, while older libraries may still expose dialect-specific operators or filter syntax.

Simple dot paths are widely recognizable, but recursive descent and filters still vary across Go, Python, Java, and JavaScript libraries. Treat an expression as portable only after testing it in the implementation you will ship.

This tutorial covers the standard core, shows where dialects diverge, and explains why query performance depends on the implementation, expression, and size of the JSON document rather than one universal complexity number.

JsonXmlEditor on Mac showing a JSON document and a focused query workflow.

Find values in any JSON response with JSONPath

  1. Anchor at document root Start query expression with $ for root node.
  2. Navigate properties Use dot notation for nested object keys like $.store.name.
  3. Target array indices Use zero-based index brackets like $.books[0].
  4. Extract array wildcards Use [*] wildcard to extract properties across all array items.
  5. Filter by conditions Apply filter predicates like [?(@.price < 15)].

A JSON response we can actually work with

Consider a multi-nested API response:

{
  "store": {
    "name": "Page & Pixel",
    "currency": "EUR",
    "books": [
      {
        "id": "bk_101",
        "title": "The Long Way Home",
        "author": "Nora Hale",
        "price": 14.99,
        "inStock": true
      },
      {
        "id": "bk_102",
        "title": "Debugging After Dark",
        "author": "Milo Grant",
        "price": 19.5,
        "inStock": false
      }
    ],
    "owner": {
      "name": "Jamie Chen",
      "email": "jamie@example.com"
    }
  }
}

All JSONPath expressions begin at the root node, denoted by `$`.

Core operators: dot notation, arrays, and wildcards

Essential JSONPath query patterns:

  • $.store.name — Dot notation for nested object properties.
  • $.store.books[0].title — Zero-indexed array element targeting.
  • $.store.books[*].title — Wildcard operator to extract property across all array elements.
  • $.user['last-login'] — Bracket notation for keys containing spaces or hyphens.

Recursive descent ($..) and filter expressions

Recursive descent (`$..id`) can search for matching names below the current node, but the amount of work depends on the implementation and input tree.

Filter syntax is one place dialects differ. Some libraries accept the legacy form `$.store.books[?(@.inStock == true)].title`; RFC 9535 uses standardized filter selectors, so check your runtime before copying a predicate between tools.

JSONPath cheat sheet and AST evaluation complexity

There is no single performance guarantee for every JSONPath expression. A full-tree search may touch many nodes, while a direct property path can do less work; benchmark the expressions that matter in your own runtime.

Frequently asked questions

What is JSONPath?
JSONPath is a query language for JSON AST payloads, similar to XPath for XML or CSS selectors for HTML.
What does $ mean in JSONPath?
The $ symbol represents the root object or array of the JSON document.
Can I test JSONPath expressions offline on Mac?
Yes. JsonXmlEditor lets you format JSON, copy exact JSONPath queries from formatted AST nodes, and test expressions locally.

Sources and further reading