12.5. JSON pathΒΆ

A JSON dot path is made up of field names, dot characters, and * (wildcard) characters. The wildcard character is used to select all the different field names. To retrieve specific values from an array, you can use the index.

In the following examples, JSON data is the JSON that is being worked on. Path is the dot path you define to retrieve one or more values from the JSON. The retrieved value shows what the specified path extracts from the JSON. You can observe the following examples to learn how to use the JSON path to retrieve values from JSON.

Example 1 (Retrieving a value):
JSON data:
{
    "product": {
        "name": "PlayStation"
    }
}
Path:

product.name

Retrieved value:
 

PlayStation

Example 2 (Using a wildcard):

You can use one or many wildcards in the path.

JSON data:
{
    "product": [
        {"name": "PlayStation"},
        {"name": "Xbox"}
    ]
}
Path:

product.*.name

Retrieved values:
 

PlayStation, Xbox

Example 3 (Using an array index):

Please note that the array indices start from 0. So, when you specify 1 as the index, you retrieve the second value.

JSON data:
{
    "product": [
        {"name": "PlayStation"},
        {"name": "Xbox"}
    ]
}
Path:

product.1.name

Retrieved value:
 

Xbox