Interface JsonPath
public interface JsonPath
JSON path abstraction for JSON commands.
Supports RedisJSON 2.0 Path syntax only. The syntax below is adapted from Goessner's path syntax comparison.
Given the JSON document:
{
"store": {
"books": [
{ "title": "Sayings of the Century", "price": 8.95 },
{ "title": "Sword of Honour", "price": 12.99 }
]
}
}
the following paths can be used to navigate the document:
$.store.books[0].title // "Sayings of the Century" $.store.books[*].price // [8.95, 12.99] $.store.books[?(@.price<10)].title // "Sayings of the Century" $..price // [8.95, 12.99]
| Syntax element | Description |
|---|---|
$ |
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 index values. Values can be omitted from the
slice (for example, [3:], [:8:2]) to use the default values: start defaults to the first
index, end defaults to the last index, and step defaults to 1. Use [*] or [:]
to select all elements. |
?() |
Filters a JSON object or array. Supports comparison operators (==, !=, <, <=,
>, >=, =~), logical operators (&&, ||, !), arithmetic operators
(+, -, *, /, %), membership operators (in, nin), set-relation
operators (subsetof, anyof, noneof), the size/sizeof and empty
operators, and parentheses ((, )). |
() |
Script expression. |
@ |
The current element, used in filter or script expressions. |
~ |
Returns the names of an object's members as a list of strings. |
- Since:
- 4.2
- Author:
- Yordan Tsintsov, Mark Paluch
- See Also:
-
Method Summary
-
Method Details
-
root
-
raw
-
asString
String asString()Returns the canonical JSON path text of this value.- Returns:
- the canonical JSON path text of this value.
-