Struct jsonpath_lib::Compiled [−][src]
pub struct Compiled { /* fields omitted */ }Expand description
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
Compile a path expression and return a compiled instance.
If parsing the path fails, it will return an error.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Compiled
impl UnwindSafe for Compiled
Blanket Implementations
Mutably borrows from an owned value. Read more
