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
When using double dot notation and a filter (like "$..@[?@=='val_b']") the matches do not have the correct path unless they are in an array.
The following is an example of a match with an incorrect path
fromjsonpath_ng.extimportparseexample= {
"key_a": "'val_a",
"key_b": "val_b"
}
matches=parse("$..@[?@=='val_b']").find(example)
assertlen(matches) ==1# This assert passesprint(matches[0].full_path) # This prints "[1]" which is not the correct pathprint(matches[0].full_path.update(example, "hello"))
# The above will print the following# {# "key_a": "'val_a", # "key_b": "val_b",# 1: "hello"#}
The following is an example of a match with the correct path.
fromjsonpath_ng.extimportparseexample= {
"key_a": "'val_a",
"key_b": ["val_a", "val_b"]
}
matches=parse("$..@[?@=='val_b']").find(example)
assertlen(matches) ==1# This assert passesprint(matches[0].full_path) # This prints "key_b.[1]" which is correctprint(matches[0].full_path.update(example, "hello"))
# The above will print the following# {# "key_a": "'val_a", # "key_b": ["val_a", "hello"],#}
The text was updated successfully, but these errors were encountered:
When using double dot notation and a filter (like
"$..@[?@=='val_b']"
) the matches do not have the correct path unless they are in an array.The following is an example of a match with an incorrect path
The following is an example of a match with the correct path.
The text was updated successfully, but these errors were encountered: