JSON Editor Online

JSONPath Examples and Query Patterns

• By JSON Editor Online Team

Complete guide to JSONPath with practical examples. Learn how to query and extract data from complex JSON structures.

What is JSONPath?

JSONPath is a query language for JSON, similar to XPath for XML. Extract specific data from complex structures.

Basic Syntax

Root node ($), child operator (.), recursive descent (..), array index ([n]), array slice ([start:end]).

Common Query Patterns

Select Root

$ - Returns the entire JSON document.

Select All Books

$.store.book[*] - Selects all books in the store.

Select by Index

$.store.book[0] - First book. $.store.book[-1] - Last book.

Recursive Descent

$..author - All author fields anywhere in the structure. Searches deeply nested objects.

Array Slicing

$.store.book[0:2] - First two books. $.store.book[-2:] - Last two books.

Filtering

$.store.book[?(@.price < 10)] - Books under $10. Filter expressions use @.

Multiple Selections

$.store.book[0,1] - First and second book. Comma-separated indices.

Wildcard Selection

$.store.* - All children of store. $..* - Everything everywhere.

Practical Examples

E-commerce queries, API response parsing, configuration extraction, log analysis.

Test Your Queries

Use our JSONPath Tester with 12 example queries to practice.

Related Articles

Back to Blog