Skip to main content

Path

Enum Path 

Source
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.

  1. A single number representing the 0-based n-th element in the Array. e.g. $[0] represents the first element in an Array.
  2. The keyword last represents 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.
  3. The keyword to between 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

Trait Implementations§

Source§

impl<'a> Clone for Path<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for Path<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for Path<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> PartialEq for Path<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> StructuralPartialEq for Path<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for Path<'a>

§

impl<'a> RefUnwindSafe for Path<'a>

§

impl<'a> Send for Path<'a>

§

impl<'a> Sync for Path<'a>

§

impl<'a> Unpin for Path<'a>

§

impl<'a> UnsafeUnpin for Path<'a>

§

impl<'a> UnwindSafe for Path<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.