pub enum Path<'a> {
Root,
Current,
DotWildcard,
RecursiveDotWildcard(Option<RecursiveLevel>),
BracketWildcard,
DotField(Cow<'a, str>),
ColonField(Cow<'a, str>),
ObjectField(Cow<'a, str>),
ArrayIndices(Vec<ArrayIndex>),
FilterExpr(Box<Expr<'a>>),
Expr(Box<Expr<'a>>),
}Expand description
Represents a valid JSON Path.
Variants§
Root
$ represents the root node or element.
Current
@ represents the current node or element being processed in the filter expression.
DotWildcard
.* represents selecting all elements in an Object.
RecursiveDotWildcard(Option<RecursiveLevel>)
.** represents recursive selecting all elements in Array and Object.
The optional RecursiveLevel indicates the selected levels.
BracketWildcard
[*] represents selecting all elements in an Array.
DotField(Cow<'a, str>)
.<name> represents selecting element that matched the name in an Object, like $.event.
The name can also be written as a string literal, allowing the name to contain special characters, like $." $price".
ColonField(Cow<'a, str>)
:<name> represents selecting element that matched the name in an Object, like $:event.
ObjectField(Cow<'a, str>)
["<name>"] represents selecting element that matched the name in an Object, like $["event"].
ArrayIndices(Vec<ArrayIndex>)
[<index1>,<index2>,..] represents selecting elements specified by the indices in an Array.
There are several forms of index.
- A single number representing the 0-based
n-thelement in the Array. e.g.$[0]represents the first element in an Array. - The keyword
lastrepresents the last element in the Array, and last minus a number represents the n-th element before the last element, e.g.$[last-1]represents the penultimate element. - The keyword
tobetween two numbers represent all elements of a range in an Array, e.g.$[1 to last]represents all the elements in the Array from the second to the last.
There can be more than one index, e.g. $[0, last-1 to last, 5] represents the first,
the last two, and the sixth element in an Array.
FilterExpr(Box<Expr<'a>>)
?(<expression>) represents selecting all elements in an object or array that match the filter expression, like $.book[?(@.price < 10)].
Expr(Box<Expr<'a>>)
<expression> standalone filter expression, like $.book[*].price > 10,
and arithmetic expression, like -$.a[*] or $.a + 3