Macro jsonpath_rust::json_path_value 
source · macro_rules! json_path_value { (&$v:expr) => { ... }; ($(&$v:expr),+ $(,)?) => { ... }; ($v:expr) => { ... }; }
Expand description
just to create a json path value of data Example:
- json_path_value(&json) = JsonPathValue::Slice(&json)
- json_path_value(&json,) = vec![JsonPathValue::Slice(&json)]
- json_path_value[&json1,&json1]=- vec![JsonPathValue::Slice(&json1),JsonPathValue::Slice(&json2)]
- json_path_value(json) = JsonPathValue::NewValue(json)
use std::str::FromStr;
use serde_json::{json,Value};
use jsonpath_rust::json_path_value;
use crate::jsonpath_rust::{JsonPathFinder,JsonPathQuery,JsonPathInst,JsonPathValue};
fn test(){
        let json: Box<Value> = serde_json::from_str("{}").unwrap();
        let path: Box<JsonPathInst> = Box::from(JsonPathInst::from_str("$..book[?(@.author size 10)].title").unwrap());
        let  finder = JsonPathFinder::new(json, path);
        let v = finder.find_slice();
        let js = json!("Sayings of the Century");
        assert_eq!(v, json_path_value![&js,]);
    }