JSONPath: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 16: Line 16:
A JSONPath expression specifies a [[JSON_Concepts#Path|path]] to an [[JSON_Concepts#Element|element]] or a set of elements that are part of a [[JSON_Concepts#JSON_Document|JSON document]]. An expression can be assembled using a series of syntax elements presented below.  
A JSONPath expression specifies a [[JSON_Concepts#Path|path]] to an [[JSON_Concepts#Element|element]] or a set of elements that are part of a [[JSON_Concepts#JSON_Document|JSON document]]. An expression can be assembled using a series of syntax elements presented below.  


There are two ways to select a specific child element relative to the parent element: .''property'' and []. These two different syntaxes are applied to JSON [[JSON_Concepts#Objects|Objects]] and [[JSON_Concepts#Arrays|Arrays]], given the fact that JSON has only these two types of collections.
There are two ways to select a specific child element relative to the parent element: [[#.property|.''property'']] and [''0-based-index'']. These two different syntaxes are applied to JSON [[JSON_Concepts#Objects|Objects]] and [[JSON_Concepts#Arrays|Arrays]], given the fact that JSON has only these two types of collections.


====<tt>.''property''</tt>====
====<tt>.''property''</tt>====
====<tt>[''n'']</tt>====
====<tt>[''0-based-index'']</tt>====


==JSONPath Template==
==JSONPath Template==

Revision as of 00:00, 16 March 2021

External

Internal

Overview

JSONPath is a query language for JSON similar to XPath for XML. Some documentation describes it as a Java DSL for reading JSON documents, probably to address those cases where the implementation is made in Java.

Concepts

JSONPath Expression

A JSONPath expression specifies a path to an element or a set of elements that are part of a JSON document. An expression can be assembled using a series of syntax elements presented below.

There are two ways to select a specific child element relative to the parent element: .property and [0-based-index]. These two different syntaxes are applied to JSON Objects and Arrays, given the fact that JSON has only these two types of collections.

.property

[0-based-index]

JSONPath Template