Guide

JSONPath Cheat Sheet: Query JSON With RFC 9535

Short answer: this JSONPath cheat sheet starts from one idea: JSONPath is a query language for picking values out of a JSON document, and since February 2024 it has a standard: RFC 9535. The quickest way to learn it is to try expressions on real data. Paste a document into the JSONPath Tester, type a query and see every match at once.

The four expressions worth memorising

These use the classic bookstore example, a store with a book array where each book has author, title, price and sometimes isbn.

You want Query
Every author, at any depth $..author
Titles of books cheaper than 10 $..book[?@.price < 10].title
The last book $..book[-1]
Titles of books that have an ISBN $..book[?@.isbn].title

How to read a query

  • $ is the root of the document.
  • .name or ['name'] selects a member.
  • .. is recursive descent: search at every depth.
  • [0] picks an array item, and a negative index such as [-1] counts from the end.
  • [?...] is a filter, and @ means "the item being tested".

So $..book[?@.price < 10].title reads: from the root, find every book at any depth, keep those whose price is below 10, and return their title.

Functions

RFC 9535 defines length, count, match, search and value. The tester supports them, so a filter can compare string lengths or test a value against a regular expression.

JSONPath is not jq

JSONPath only selects. It does not reshape, calculate or build new documents. If you need to transform data (for example, flattening JSON into CSV rows), that is a different tool. The tester follows RFC 9535 but is not an officially certified implementation, and other libraries, especially older ones, can behave differently on edge cases. Test against the library you will use in production.

How to use the JSONPath Tester with this cheat sheet

  1. Open the JSONPath Tester.
  2. Paste your JSON. If it will not parse, check it first in the JSON Validator; the guide to JSON unexpected token errors explains the usual causes.
  3. Enter a query and read the matches.
  4. Adjust the filter until only the values you want remain.

Limits to know

  • Not certified against RFC 9535; verify critical queries in your own library.
  • It is a selector language, not a transformer.
  • Everything runs in your browser.

Frequently asked questions

What is RFC 9535? The IETF standard for JSONPath, published in February 2024.

How do I get the last item of an array? Use a negative index: $..book[-1].

What does .. mean? Recursive descent: look at every level below the current one.

Is JSONPath the same as jq? No. JSONPath selects values; jq can also transform them.

How do I find items that have a field? Use an existence filter: $..book[?@.isbn].

Related tools and guides

Sources and further reading