Open martinohmann opened 2 years ago
@freestrings I saw that this was already fixed in https://github.com/freestrings/jsonpath/commit/c3b973437cddbd05fc41796e7a2ddb7b998150a2, sorry for the duplication.
Is it possible to publish a patch release for this?
@martinohmann The next release is being delayed. I will do a minor release first as soon as possible. Thanks for reporting the issue.
I ran into the same issue. After seeing the last comment I tried out the current master version (https://github.com/freestrings/jsonpath#1a84c5af9445e617a6deed14dadfaee13af0d95f). There the panic did not occur any more, but when deleting values in the replace_with() method, values which are located directly after a deleted value are ignored.
here a test to reproduce:
#[test]
fn delete_in_replace() {
let input = json!({
"myList": [
"BLUE",
"ORANGE",
"GREEN",
"RED"
]
});
let output = jsonpath_lib::replace_with(input, "$.myList[*]", &mut |_| None)
.expect("replace to succeed");
assert_eq!(json!({"myList": []}), output);
}
which results in:
thread 'tests::delete_in_replace' panicked at 'assertion failed: `(left == right)`
left: `Object({"myList": Array([])})`,
right: `Object({"myList": Array([String("ORANGE"), String("RED")])})`'
Hi,
I discovered the following panic while using
SelectorMut::remove
:The
jsonpath_lib
version is0.3.0
. Here is a minimal reproducer:I expected
mutated
to contain an empty array, but got this panic instead. Please note that when using.delete()
instead of.remove()
this code does not panic but produces the expected result of an array which contains only nulls.I suspect that the array length isn't recalculated correctly after removing elements.