Closed baynes closed 1 year ago
The filter() function does not work when there is a filter expression in the jsonpath, and it throws a NotImplementedError. Code to duplicate this error:
obj = {
"a": [
{"b": "X"},
{"b": "Y"}
]
}
jsonpath = parse("$.a[?(@.b==X)]")
matches = jsonpath.find(obj)
print(matches[0].value)
>>> {'b': 'X'} # find() returns correct value
result = jsonpath.filter(lambda x: True, obj)
>>> NotImplementedError # filter() throws error
The filter() function does not work when there is a filter expression in the jsonpath, and it throws a NotImplementedError. Code to duplicate this error:
obj = { "a": [ {"b": "X"}, {"b": "Y"} ] } jsonpath = parse("$.a[?(@.b==X)]") matches = jsonpath.find(obj) print(matches[0].value) >>> {'b': 'X'} # find() returns correct value result = jsonpath.filter(lambda x: True, obj) >>> NotImplementedError # filter() throws error
@WilliamYuhangLee: I think what you have found is an interaction between the use of filter member function and the filter extensions to JSONPath. I don't think it affects my proposed documentation additions above. I suggest you raise what you have found as a separate issue.
@baynes I added these examples. Thanks!
The examples in the READMEdo not cover the update and filter functions. There is no documentation on these leading to puzzles as how to use them - see #42 - and many readers may not even realize the functionality is even there. I propose the following is added: