[−][src]Function jsonpath_lib::select
pub fn select(json: &Value, path: &str) -> Result<Value, String>
This function compile a jsonpath everytime and it convert serde_json's Value
to jsonpath's RefValue
everytime and then it return a serde_json::value::Value
.
extern crate jsonpath_lib as jsonpath; #[macro_use] extern crate serde_json; let json_obj = json!({ "school": { "friends": [ {"name": "친구1", "age": 20}, {"name": "친구2", "age": 20} ] }, "friends": [ {"name": "친구3", "age": 30}, {"name": "친구4"} ]}); let json = jsonpath::select(&json_obj, "$..friends[0]").unwrap(); let ret = json!([ {"name": "친구3", "age": 30}, {"name": "친구1", "age": 20} ]); assert_eq!(json, ret);