[−][src]Struct jsonpath_lib::Compiled
A pre-compiled expression.
Calling the select function of this struct will re-use the existing, compiled expression.
Example
extern crate jsonpath_lib as jsonpath; #[macro_use] extern crate serde_json; let mut first_friend = jsonpath::Compiled::compile("$..friends[0]").unwrap(); let json_obj = json!({ "school": { "friends": [ {"name": "친구1", "age": 20}, {"name": "친구2", "age": 20} ] }, "friends": [ {"name": "친구3", "age": 30}, {"name": "친구4"} ]}); // call a first time let json = first_friend.select(&json_obj).unwrap(); assert_eq!(json, vec![ &json!({"name": "친구3", "age": 30}), &json!({"name": "친구1", "age": 20}) ]); // call a second time let json = first_friend.select(&json_obj).unwrap(); assert_eq!(json, vec![ &json!({"name": "친구3", "age": 30}), &json!({"name": "친구1", "age": 20}) ]);
Implementations
impl Compiled
[src]
pub fn compile(path: &str) -> Result<Compiled, String>
[src]
Compile a path expression and return a compiled instance.
If parsing the path fails, it will return an error.
pub fn select<'a>(
&self,
value: &'a Value
) -> Result<Vec<&'a Value>, JsonPathError>
[src]
&self,
value: &'a Value
) -> Result<Vec<&'a Value>, JsonPathError>
Execute the select operation on the pre-compiled path.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Compiled
[src]
impl Send for Compiled
[src]
impl Sync for Compiled
[src]
impl Unpin for Compiled
[src]
impl UnwindSafe for Compiled
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,