JSON Path: Extract JSON Nodes Like XPath

2026-02-26

Deep API responses make hand-written paths tedious. JSONPath helps configurable extraction, tests, and ops rules.

Basics

$ root; .name; [0]; [*]; ..key recursive. RFC 9535 standardizes JSONPath.

// $.store.book[*].title    ["A", "B"]

Filters

[?(@.price < 10)] filters array elements; @ is current node.

Tools

JS: jsonpath-plus; Python: jsonpath-ng; CLI: jq .store.book[].title

Vs XPath

JSONPath targets JSON values—no attributes/text nodes like XML.

Practice

Production: fixed paths + schema; JSONPath for ops, tests, config.