Skip to main content
In this guide, you’ll learn how to leverage JSONPath expressions to query, filter, and slice JSON arrays effectively. JSONPath is a powerful query language for JSON, enabling developers to pinpoint data within nested structures, perform conditional selections, and iterate through collections.

1. Defining an Array in JSON

Consider a JSON document representing a set of users:
Here, users is an array of objects. Each object has id, name, and age properties.

2. Accessing Array Elements

2.1 By Index

Pick a single element by its zero-based index:
Returns:
Returns:

2.2 Using Wildcard

Retrieve all users with the wildcard *:
Returns:

2.3 Slicing the Array

Extract a range of elements with slice notation [start:end]:
Returns:
You can omit start or end:
  • [:2] → first two elements
  • [2:] → from the third element onward
JSONPath uses zero-based indices. Negative indices or step values (e.g., [::2]) are not supported in all implementations.

3. Filtering Array Elements

Apply a filter expression to select items matching a condition:
Returns users aged 25 or older:

3.1 Accessing Properties of Filtered Results

Chain selectors to extract specific fields:
Returns:

4. Nested Arrays

Given nested arrays, you can flatten or traverse them:
List all members across every group:
Returns:

5. Summary of JSONPath List Operators

By mastering these operators, you can query, transform, and navigate JSON arrays with precision.

Watch Video

Practice Lab