JSONPath
JSONPath is a query language for selecting and extracting values from JSON data.
BDD in Action, Second Edition
A JSONPath expression is a query expression for selecting or evaluating values within JSON data.
- How it is used
- Supports API acceptance tests by selecting expected values from REST responses without exercising the user interface.
- How deep it goes
- Demonstrates scalar, nested, typed, object, and collection extraction but does not develop JSONPath grammar or implementation internals.
- Examples
- Uses frequent-flyer registration, passport lookup, and flight-history extraction as concrete query examples.
- What you can do after
- Apply it via Rest Assured to extract scalar values, nested objects, or collections from API responses.
Automating API Delivery
A JSONPath expression is a query expression that selects or navigates elements in a JSON document.
- How it is used
- Locates OpenAPI definition elements for Spectral rules that automate API style-guide checks.
- How deep it goes
- Defines root and child navigation, then works through rule targets and JSONPath Plus path-name selection without developing a full query-language reference.
- Examples
- Uses `$.info`, `$.paths[*]~`, and `$.paths[*].get.operationId` to target descriptions, URI paths, and GET operation IDs.
- What you can do after
- Apply it via Spectral to target linting checks, and test JSONPath Plus selections with `jpp` before running a rule.
The Design of Web APIs, Second Edition
JSONPath is a query language and expression syntax for selecting and extracting values from JSON-like hierarchical data.
- How it is used
- Targets OpenAPI elements in a Spectral rule's `given` before `then` checks their values.
- How deep it goes
- Works through root selection, wildcards, recursive search, key alternatives, filters, and selector testing; defers implementation-specific details to JSONPath Plus documentation.
- Examples
- Uses API versions, query-parameter names, POST and PUT responses, and query or path parameters as selection targets.
- What you can do after
- Apply it via Spectral to target lint checks and verify selected locations with a temporary `undefined` check.
Read how The Design of Web APIs, Second Edition explains JSONPath →
Also covered in
What to know first
- OpenAPI specificationThe OpenAPI Specification is a machine-readable standard for describing HTTP APIs, including their operations, inputs, outputs, data structures, and security requirements.
Related concepts
- linter ruleused by · A linter rule is a condition or constraint that a linter checks against code or another structured artifact to detect or report patterns or violations.
- Spectralused by · Spectral is an open-source linter that applies configurable rules to JSON, YAML, and structured API description documents.
- api calluses · An API call is a programmatic request or invocation sent through an application programming interface to retrieve data or invoke an exposed operation.
- REST Assuredused by · REST Assured is a Java library for testing RESTful web services through programmatic HTTP requests and response assertions.
- Spring Boot testused by · Spring Boot testing support provides facilities for testing application code with Spring-managed components, configuration, and framework behavior.
- XPathcontrasts with · XPath is a language for navigating and selecting nodes in structured documents, especially XML documents.
Questions about JSONPath
What is JSONPath?
JSONPath is a query language for selecting and extracting values from JSON data.
Which Manning books explain JSONPath?
BDD in Action, Second Edition, Automating API Delivery and The Design of Web APIs, Second Edition.
What should I know before learning JSONPath?
Manning books that teach JSONPath usually introduce OpenAPI specification first.
What is the difference between JSONPath and XPath?
JSONPath is a query language for selecting and extracting values from JSON data. XPath is a language for navigating and selecting nodes in structured documents, especially XML documents.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


