json.path

This function allows you to query an element within JSON data. In order to reach the desired node or a specific field in the node in the JSON data, you must follow a specific notation defined in the JsonPath specification. See https://github.com/oliveagle/jsonpath for details on the notation to be used and specific examples of using the notation.

Important: See the section Mapping JSON Data with the json.path() Function for a detailed explanation on using the json.path() function.

Syntax

json.path(path, object)

Arguments

Argument

Type

Description

path

string

The search path to the element within the JSON data.

object

any

The JSON object that contains the JSON data you are searching.

Returns

Type

Description

any

The result of the JSON path.

Examples

Let's say the jsonObject includes the following: 

jsonObject = {
"colors": [
{ "id": 1, "value": "red" },
{ "id": 2, "value": "green" },
{ "id": 3, "value": "blue" }
]
}

The function json.path("$loop.colors[?(@.id == 2)].value[0]", jsonObject) returns green.