{}JSON FYI

JSONPath cheatsheet: selectors, wildcards, and filters

Everything you need to query JSON: dot vs bracket notation, wildcards, slices, and filter expressions.

·6 min read

Basics

  • $ — root
  • .key — child by name
  • ["key with spaces"] — quoted child
  • [0] — array index (0-based)
  • [-1] — last item (some implementations)

Wildcards & recursion

  • .* — every child
  • ..key — recursive descent (find key at any depth)

Slices

[start:end:step] — like Python. [0:5] gets the first five elements; [::2] every other.

Filter expressions

$.users[?(@.age > 18)].name
$.products[?(@.price < 100 && @.inStock)]

Examples

$               -> whole document
$.users[0]      -> first user
$.users[*].id   -> every id
$..email        -> every email at any depth

Frequently asked questions

JSONPath vs JMESPath vs jq?+

JSONPath is the original; JMESPath is a stricter spec used by AWS; jq is a full query language with its own syntax. Pick what your tooling supports.

Related tools & guides