{FormJSON}
Querying & Filtering JSONPath Reference 7 Min Read

JSONPath Syntax Guide: Filtering Expressions & Query Recipes

A reference manual and practical cheat sheet for navigating, querying, and filtering deeply nested JSON payloads.

Test your JSONPath expression interactively
Evaluate complex filters with instant visual node highlights in FormJson's console.
Launch JSONPath Console →

1. JSONPath Operators Cheat Sheet

Symbol Operator Name Description & Example
$ Root Element Represents the root object or array: $
@ Current Node The active item being processed inside a filter: [?(@.age > 21)]
.. Recursive Descent Finds keys anywhere in the hierarchy: $..author
* Wildcard Matches all keys or array elements: $.users.*
[start:end:step] Array Slice Python-style slice notation: $.items[0:5] (first 5 items)
[?()] Filter Expression Evaluates logical boolean expressions: $[?(@.active == true)]

2. Production Query Recipes

Extract all emails from deeply nested user objects
$..email

Scans every object at any depth and returns a flat array of email values.

Find orders exceeding $500 with 'COMPLETED' status
$.orders[?(@.total > 500 && @.status == 'COMPLETED')]

Combines relational comparison with logical AND operators.

Select the last 3 items in an event log array
$.events[-3:]

Uses negative index slice notation to grab trailing array elements without calculating length.

Frequently Asked Questions

FAQ

What is JSONPath and what is it used for?
JSONPath is a query expression language for JSON, analogous to XPath for XML. It allows developers to extract, filter, and transform specific values from deeply nested JSON documents using concise path strings.
What does '$..' mean in JSONPath?
The double dot operator ('$..') represents recursive descent. It searches for matching property names across all nesting levels of the entire JSON hierarchy.
How do I filter JSON elements by a condition?
Use the filter expression syntax '[?(<expression>)]'. For example, '$.store.book[?(@.price < 10)]' extracts only books with a price strictly under 10.
Can I query JSONPath directly in the browser?
Yes! FormJson provides an interactive JSONPath Console (/jsonpath) with real-time matched node highlighting and zero data leakage.