Learn
What is JSONPath?
Direct answer: JSONPath is a query language for selecting and extracting values from JSON documents, similar to how XPath works for XML. Expressions typically start with $ (the root) and use dots, brackets, and wildcards to navigate nested fields.
Step-by-step
Step 1
Start at the root
Use $ to refer to the entire document.
Step 2
Walk properties
Use .field or ['field'] to descend into objects.
Step 3
Select arrays
Use [0], [*], or [?(@.price<10)] style filters depending on your engine.
Examples
Select all author names
$.store.book[*].author
First item SKU
$.data.items[0].sku
Nested preference
$.user.profile.preferences.theme
FAQ
Is JSONPath standardized?
Implementations vary. Stick to widely supported features (root, property access, array indexes, wildcards) for portability.
JSONPath vs jq?
JSONPath focuses on selection. jq is a full programming language for transforming JSON streams.