Getting familiar with the JSONPath notation

In order to parse JSON structures, we use JSONPath. JSONPath is the XPath for JSON; it's used to refer to JSON elements in the same way as XPath is used for XML elements.

JSONPath expressions use dot notation, as in $.store.book[0].title.

The following table shows a basic overview of the JSONPath syntax elements. The examples refer to the book's structure presented earlier:

JSONPath expression

Description

Sample

$

Root object

$ returns the whole JSON structure

.

Child operator; it's used to access different levels of the JSON structure

$..title returns the titles of the books

*

Wildcard for referring to all elements

$.store.book.* returns all books

[]

Array ...

Get Learning Pentaho Data Integration 8 CE - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.