pub fn reader(json: Value) -> impl FnMut(&str) -> Result<Value, String>
extern crate jsonpath_lib as jsonpath;
#[macro_use] extern crate serde_json;
let json_obj = json!({
"school": {
"friends": [{"id": 0}, {"id": 1}]
},
"friends": [{"id": 0},{"id": 1}]
});
let mut reader = jsonpath::reader(json_obj);
let json = reader("$..friends[0]").unwrap();
let ret = json!([ {"id": 0}, {"id": 0} ]);
assert_eq!(json, ret);
let json = reader("$..friends[1]").unwrap();
let ret = json!([ {"id": 1}, {"id": 1} ]);
assert_eq!(json, ret);