JSONPath Basics
JsonPath is a simple and powerful tool for extracting specific data from JSON documents. It is a query language that allows you to navigate through the JSON structure and access the values you need.
JsonPath uses a dot notation syntax, allowing you to specify the path to the desired value.
The most important symbols used in a JSONPath
JSONPath Syntax | Description |
---|---|
| the root element. A JSONPath mostly starts with this symbol |
| the current element |
| child operator |
| wildcard. Targets all elements of a list |
| defines an element filter |
| AND operator |
| OR operator |
Example JSON
{
"result": [
{
"id": 1,
"name": "Wooden Gloves"
},
{
"id": 2,
"name": "Fresh Wood"
}
]
}
Example JSONPath
JSONPath | Result |
---|---|
|
JSON
|
|
JSON
|
|
JSON
|
|
JSON
|
|
JSON
|
|
JSON
|
| 2 |
|
JSON
|
|
JSON
|
Helpful links
A simple JSONPath sandbox to play around with can be found here and the JSONPath expression definition here