JSONPath
In computer software, JSONPath is a query language for querying values in JSON. The uses of JSONPath include:
- Selecting a specific node in a JSON value
- Retrieving a set of nodes from a JSON value, based on specific criteria
- Navigating through complex JSON values to retrieve the required data.
$.foo.Example
The JSONPath expression applied to the following JSON value:selects the first book :
The expression extracts the prices of books: 8.95 and 22.99.
The expression extracts all the prices: 8.95, 22.99, and 399.
History
JSONPath was first described in an online article by Stefan Gössner in February 2007. Gössner also published initial implementations in JavaScript and PHP.Subsequently, over fifty implementations were created in various programming languages. The JSONPath Comparison Project lists many of these implementations and compares their behavior. JSONPath is widely used in the Java ecosystem.
In 2024, the IETF published a standard for JSONPath as.
Research
Scalable Processing of Contemporary Semi-Structured Data on Commodity Parallel Processors - A Compilation-based Approach describes an optimisation which converts JSONPath queries into parallel programs with bounded memory requirements.Supporting Descendants in SIMD-Accelerated JSONPath describes an optimisation of JSONPath descendant queries when streaming potentially very large JSON values.τJSONPath: A Temporal Extension of the JSONPath Language for the τJSchema Framework describes a temporal extension of JSONPath that supports querying the versions of a JSON value over its version history.Alternatives
- JMESPath is a query language for JSON with features that go far beyond JSONPath. It has a specification, a compliance test suite, and multiple implementations in various languages.
- JSONata An open source query and transformation language for JSON data inspired by XPath 3.1.
- JSON Pointer defines a string syntax for identifying a single value within a given JSON value of known structure.
- JSONiq is a query and transformation language for JSON.
- XPath 3.1 is an expression language that allows the processing of values conforming to the XDM data model. The version 3.1 of XPath supports JSON as well as XML.
- is like for JSON data – it can be used to slice and filter and map and transform structured data.
- ZPath is a query language for structured data including JSON, CBOR and XML