Macro jsonpath_rust::jp_v
source · macro_rules! jp_v { (&$v:expr) => { ... }; (&$v:expr ; $s:expr) => { ... }; ($(&$v:expr;$s: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::jp_v;
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, jp_v![&js;"",]);
}