Paradigm | Query language |
---|---|
Designed by | Stefan Gössner |
Developer | Stefan Gössner |
First appeared | 2007 (blogged) 2024 (standardized) |
Influenced by | |
XPath |
Status | Proposed Standard |
---|---|
Year started | February 2024 |
Organization | IETF |
Editors | Stefan Gössner Glyn Normington Carsten Bormann |
Authors | Stefan Gössner |
Base standards | JSON |
Related standards | XPath |
In computer software, JSONPath is a query language for querying values in JSON. The uses of JSONPath include:
JSONPath queries are path expressions written as strings, e.g. $.foo
.
The JSONPath expression $.store.book[0]
applied to the following JSON value:
{"store":{"book":[{"author":"Nigel Rees","title":"Sayings of the Century","price":8.95},{"author":"J. R. R. Tolkien","title":"The Lord of the Rings","isbn":"0-395-19395-8","price":22.99}],"bicycle":{"color":"red","price":399}}}
selects the first book (by Nigel Rees):
{"author":"Nigel Rees","title":"Sayings of the Century","price":8.95}
The expression $.store.book[*].price
extracts the prices of books: 8.95 and 22.99 (since [*]
selects all the nodes of an array).
The expression $..price
extracts all the prices: 8.95, 22.99, and 399.
JSONPath was first described in an online article [1] 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. [2] JSONPath is widely used in the Java ecosystem. [3]
In 2024, the IETF published a standard for JSONPath as RFC 9535. [4]