public class JsonPath extends Object
JsonValue
inside a JSON document.
The Redis server implements its own JSONPath implementation, based on existing technologies. The generic rules to build a path string are:
$
- The root (outermost JSON element), starts the path.. or []
- Selects a child element...
- Recursively descends through the JSON document.*
- Wildcard, returns all elements.[]
- Subscript operator, accesses an array element.[,]]
- Union, selects multiple elements.[start:end:step]
- Array slice where start, end, and step are indexes.?()
- Filters a JSON object or array. Supports comparison operators (==, !=, <, <=, >, >=, =~), logical
operators (&&, ||), and parenthesis ((, )).()
- Script expression.@
- The current element, used in filter or script expressions.For example, given the following JSON document:
{ "inventory": { "mountain_bikes": [ { "id": "bike:1", "model": "Phoebe", "description": "This is a mid-travel trail slayer that is a fantastic daily...", "price": 1920, "specs": {"material": "carbon", "weight": 13.1}, "colors": ["black", "silver"], }, ... } } }
To get a list of all the mountain_bikes
inside the inventory
you would write something like:
JSON.GET store '$.inventory["mountain_bikes"]'
Modifier and Type | Field and Description |
---|---|
static JsonPath |
ROOT_PATH
The root path
$ as defined by the second version of the RedisJSON implementation. |
static JsonPath |
ROOT_PATH_LEGACY
Deprecated.
since 6.5, use
ROOT_PATH instead. |
Constructor and Description |
---|
JsonPath(String pathString)
Create a new
JsonPath given a path string. |
Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object obj) |
int |
hashCode() |
boolean |
isRootPath() |
static JsonPath |
of(String path)
Create a new
JsonPath given a path string. |
String |
toString() |
public static final JsonPath ROOT_PATH
$
as defined by the second version of the RedisJSON implementation.
Copyright © 2025 lettuce.io. All rights reserved.