JSONPath

Last updated
JSONPath
Paradigm Query language
Designed by Stefan Gössner
Developer Stefan Gössner
First appeared2007 (blogged)
2024 (standardized)
Influenced by
XPath
JSONPath
StatusProposed Standard
Year startedFebruary 2024 (2024-02)
Organization IETF
EditorsStefan Gössner
Glyn Normington
Carsten Bormann
AuthorsStefan 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:

Contents

JSONPath queries are path expressions written as strings, e.g. $.foo.

Example

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.

History

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]

Research

Alternatives

Related Research Articles

<span class="mw-page-title-main">Document Object Model</span> Convention for representing and interacting with objects in HTML, XHTML, and XML documents

The Document Object Model (DOM) is a cross-platform and language-independent interface that treats an HTML or XML document as a tree structure wherein each node is an object representing a part of the document. The DOM represents a document with a logical tree. Each branch of the tree ends in a node, and each node contains objects. DOM methods allow programmatic access to the tree; with them one can change the structure, style or content of a document. Nodes can have event handlers attached to them. Once an event is triggered, the event handlers get executed.

<span class="mw-page-title-main">SOAP</span> Messaging protocol for web services

SOAP is a messaging protocol specification for exchanging structured information in the implementation of web services in computer networks. It uses XML Information Set for its message format, and relies on application layer protocols, most often Hypertext Transfer Protocol (HTTP), although some legacy systems communicate over Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission.

<span class="mw-page-title-main">XML</span> Markup language by the W3C for encoding of data

Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing arbitrary data. It defines a set of rules for encoding documents in a format that is both human-readable and machine-readable. The World Wide Web Consortium's XML 1.0 Specification of 1998 and several other related specifications—all of them free open standards—define XML.

XSLT is a language originally designed for transforming XML documents into other XML documents, or other formats such as HTML for web pages, plain text or XSL Formatting Objects, which may subsequently be converted to other formats, such as PDF, PostScript and PNG. Support for JSON and plain-text transformation was added in later updates to the XSLT 1.0 specification.

XSD, a recommendation of the World Wide Web Consortium (W3C), specifies how to formally describe the elements in an Extensible Markup Language (XML) document. It can be used by programmers to verify each piece of item content in a document, to assure it adheres to the description of the element it is placed in.

Saxon is an XSLT and XQuery processor created by Michael Kay and now developed and maintained by his company, Saxonica. There are open-source and also closed-source commercial versions. Versions exist for Java, JavaScript and .NET.

<span class="mw-page-title-main">JSON</span> Open standard file format and data interchange

JSON is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays. It is a commonly used data format with diverse uses in electronic data interchange, including that of web applications with servers.

In computer hypertext, a URI fragment is a string of characters that refers to a resource that is subordinate to another, primary resource. The primary resource is identified by a Uniform Resource Identifier (URI), and the fragment identifier points to the subordinate resource.

<span class="mw-page-title-main">NETCONF</span> Network management protocol

The Network Configuration Protocol (NETCONF) is a network management protocol developed and standardized by the IETF. It was developed in the NETCONF working group and published in December 2006 as RFC 4741 and later revised in June 2011 and published as RFC 6241. The NETCONF protocol specification is an Internet Standards Track document.

XML documents have a hierarchical structure and can conceptually be interpreted as a tree structure, called an XML tree.

XQuery Update Facility is an extension to the XML Query language, XQuery. It provides expressions that can be used to make changes to instances of the XQuery 1.0 and XPath 2.0 Data Model.

XPath is an expression language designed to support the query or transformation of XML documents. It was defined by the World Wide Web Consortium (W3C) in 1999, and can be used to compute values from the content of an XML document. Support for XPath exists in applications that support XML, such as web browsers, and many programming languages.

XQuery is a query and functional programming language that queries and transforms collections of structured and unstructured data, usually in the form of XML, text and with vendor-specific extensions for other data formats. The language is developed by the XML Query working group of the W3C. The work is closely coordinated with the development of XSLT by the XSL Working Group; the two groups share responsibility for XPath, which is a subset of XQuery.

<span class="mw-page-title-main">XQuery API for Java</span> Application programming interface

XQuery API for Java (XQJ) refers to the common Java API for the W3C XQuery 1.0 specification.

<span class="mw-page-title-main">BaseX</span> XML database management and query system

BaseX is a native and light-weight XML database management system and XQuery processor, developed as a community project on GitHub. It is specialized in storing, querying, and visualizing large XML documents and collections. BaseX is platform-independent and distributed under the BSD-3-Clause license.

Zorba is an open source query processor written in C++, implementing

Tritium is a simple scripting language for efficiently transforming structured data like HTML, XML, and JSON. It is similar in purpose to XSLT but has a syntax influenced by jQuery, Sass, and CSS versus XSLT's XML based syntax.

JSONiq is a query and functional programming language that is designed to declaratively query and transform collections of hierarchical and heterogeneous data in format of JSON, XML, as well as unstructured, textual data.

XPath 3 is the latest version of the XML Path Language, a query language for selecting nodes in XML documents. It supersedes XPath 1.0 and XPath 2.0.

Shapes Constraint Language (SHACL) is a World Wide Web Consortium (W3C) standard language for describing Resource Description Framework (RDF) graphs. SHACL has been designed to enhance the semantic and technical interoperability layers of ontologies expressed as RDF graphs.

References

  1. Gössner, Stefan. "JSONPath - XPath for JSON". Archived from the original on 11 September 2007. Retrieved 22 March 2024.
  2. Burgmer, Christoph. "JSONPath Comparison". Archived from the original on 3 March 2024. Retrieved 22 March 2024.
  3. Friesen, Jeff (11 January 2019). "Extracting JSON values with JsonPath". Java XML and JSON: Document Processing for Java SE (2nd ed.). Apress. ISBN   978-1484243299.
  4. Gössner, Stefan; Normington, Glyn; Bormann, Carsten (February 2024). "RFC 9535 JSONPath: Query Expressions for JSON". The RFC Series. The Internet Engineering Task Force (IETF). Retrieved 22 March 2024.
  5. Jiang, Lin; Sun, Xiaofan; Farooq, Umar; Zhao, Zhijia (April 2019). "Scalable Processing of Contemporary Semi-Structured Data on Commodity Parallel Processors - A Compilation-based Approach". Proceedings of the Twenty-Fourth International Conference on Architectural Support for Programming Languages and Operating Systems. pp. 79–92. doi:10.1145/3297858.3304008. ISBN   978-1-4503-6240-5.
  6. Gienieczko, Mateusz; Murlak, Filip; Paperman, Charles (February 2024). "Supporting Descendants in SIMD-Accelerated JSONPath". Conference on Architectural Support for Programming Languages and Operating Systems. 4.
  7. Brahmia, Zouhaier; Grandi, Fabio; Brahmia, Safa; Bouaziz, Rafik (2023). "τJSONPath: A Temporal Extension of the JSONPath Language for the τJSchema Framework". Artificial Intelligence and Smart Environment. Lecture Notes in Networks and Systems. Vol. 635. pp. 844–853. doi:10.1007/978-3-031-26254-8_123. ISBN   978-3-031-26253-1.
  8. Saryerwinnie, James. "JMESPath". Archived from the original on 14 March 2024. Retrieved 23 March 2024.
  9. Bailey, Matt. "JSONata". Archived from the original on 25 March 2024. Retrieved 25 March 2024.
  10. Bryan, Paul; Zyp, Kris; Nottingham, Mark (April 2013). "RFC 6901 JavaScript Object Notation (JSON) Pointer". The RFC Series. The Internet Engineering Task Force (IETF). Retrieved 23 March 2024.
  11. "JSONiq". Archived from the original on 13 January 2024. Retrieved 23 March 2024.
  12. Robie, Jonathan; Dyck, Michael; Spiegel, Josh. "XML Path Language (XPath) 3.1". w3c.org. Archived from the original on 18 January 2024. Retrieved 24 March 2024.
  13. Tovey-Walsh, Norman; Snelson, John; Coleman, Andrew. "XQuery and XPath Data Model". w3c.org. Archived from the original on 18 January 2024. Retrieved 24 March 2024.