Jsonpath with bool values or null panics
yuriy-mochurad opened this issue · comments
Yuriy Mochurad commented
I am not able to use jsonpath that has bool or null values, even though it is mentioned in README. For example this code based on example:
use serde_json::{json,Value};
use jsonpath_rust::json_path_value;
use jsonpath_rust::JsonPathFinder;
use jsonpath_rust::JsonPathValue;
fn main(){
let finder = JsonPathFinder::from_str(r#"{"first":{"second":[{"active":1},{"passive":1}]}}"#, "$.first.second[?(@.active == true)]").unwrap();
let slice_of_data:Vec<JsonPathValue<Value>> = finder.find_slice();
let js = json!({"active":1});
assert_eq!(slice_of_data, json_path_value![&js,]);
}
It is based on the example. Notice the jsonpath string is: $.first.second[?(@.active == true)]
The error when running is:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: " --> 1:30\n |\n1 | $.first.second[?(@.active == true)]\n | ^---\n |\n = expected atom"', src/main.rs:7:139
Looks like this case is not added to grammar rules
Yuriy Mochurad commented
Potential fix: #23
Boris Zhguchev commented
That is true. I don't see any traces of true|false|null
literals in gramma.
Boris Zhguchev commented
closed by #23