What is JSONPath?
JSONPath is a query language for JSON, similar to XPath for XML. It lets you extract specific values from complex nested JSON documents using path expressions. JSONPath is used in AWS CloudFormation, Kubernetes, Grafana, Postman tests, and many API tools.
Core JSONPath Syntax
$— Root of the document.key— Child property access..key— Recursive descent (find key anywhere)[*]— All array elements[0]— Array index access[?(@.age > 18)]— Filter expression[0:3]— Array slice
Common JSONPath Use Cases
- Extracting nested values from API responses in Postman tests
- AWS CloudFormation cross-stack references
- Kubernetes JSON patch operations
- Grafana dashboard variable queries