Struct jmespath::Expression
[−]
[src]
pub struct Expression<'a> { /* fields omitted */ }
A compiled JMESPath expression.
The compiled expression can be used multiple times without incurring
the cost of re-parsing the expression each time. The expression may
be shared between threads if JMESPath is compiled with the sync
feature, which forces the use of an Arc
instead of an Rc
for
runtime variables.
Methods
impl<'a> Expression<'a>
[src]
fn new<S>(expression: S, ast: Ast, runtime: &'a Runtime) -> Expression<'a> where
S: Into<String>,
S: Into<String>,
Creates a new JMESPath expression.
Normally you will create expressions using either jmespath::compile()
or using a jmespath::Runtime.
fn search<T: ToJmespath>(&self, data: T) -> Result<Rcvar, JmespathError>
Returns the result of searching data with the compiled expression.
The SearchResult contains a JMESPath Rcvar, or a reference counted Variable. This value can be used directly like a JSON object. Alternatively, Variable does implement Serde serialzation and deserialization, so it can easily be marshalled to another type.
fn as_str(&self) -> &str
Returns the JMESPath expression from which the Expression was compiled.
Note that this is the same value that is returned by calling
to_string
.
fn as_ast(&self) -> &Ast
Returns the AST of the parsed JMESPath expression.
This can be useful for debugging purposes, caching, etc.