You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
For my use case I need to remove values for specific conditions.
I tried to do that by use the replace method, but ran into a panic when using replace at all.
Occured on version 0.1.0
Here a short test to reproduce:
#[test]
fn test_replace() {
let input = json!({"list": ["red", "green", "blue"]});
let path = jsonpath_plus::JsonPath::compile("$.list[*]").expect("jsonpath is valid");
let output = path.replace(&input, |_| json!("black"));
assert_eq!(output, json!({"list": ["black", "black", "black"]}))
}
The output was:
thread 'tests::test_replace' panicked at 'explicit panic', /Users/sp/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonpath-plus-0.1.0/src/eval.rs:39:18
stack backtrace:
0: rust_begin_unwind
at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/std/src/panicking.rs:498:5
1: core::panicking::panic_fmt
at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/panicking.rs:107:14
2: core::panicking::panic
at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/panicking.rs:48:5
3: jsonpath_plus::eval::Idx::as_string
at /Users/sp/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonpath-plus-0.1.0/src/eval.rs:39:18
4: jsonpath_plus::resolve_path
at /Users/sp/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonpath-plus-0.1.0/src/lib.rs:40:53
5: jsonpath_plus::<impl jsonpath_plus::ast::Path>::replace
at /Users/sp/.cargo/registry/src/github.com-1ecc6299db9ec823/jsonpath-plus-0.1.0/src/lib.rs:132:30
6: jsonpath_filter::tests::test_replace
at ./src/lib.rs:223:22
7: jsonpath_filter::tests::test_replace::{{closure}}
at ./src/lib.rs:220:5
8: core::ops::function::FnOnce::call_once
at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops/function.rs:227:5
9: core::ops::function::FnOnce::call_once
at /rustc/db9d1b20bba1968c1ec1fc49616d4742c1725b4b/library/core/src/ops/function.rs:227:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
test tests::test_replace ... FAILED
The text was updated successfully, but these errors were encountered:
For my use case I need to remove values for specific conditions.
I tried to do that by use the replace method, but ran into a panic when using replace at all.
Occured on version 0.1.0
Here a short test to reproduce:
The output was:
The text was updated successfully, but these errors were encountered: