h2non / jsonpath-ng

Finally, a JSONPath implementation for Python that aims to be standard compliant. That's all. Enjoy!
Apache License 2.0
582 stars 85 forks source link

filter() throws NotImplementedError when there is a filter expression in jsonpath #54

Closed WilliamYuhangLee closed 10 months ago

WilliamYuhangLee commented 4 years 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
iamyourexpert commented 4 years ago

@WilliamYuhangLee fixed in https://github.com/h2non/jsonpath-ng/pull/41

kurtmckee commented 10 months ago

@michaelmior @h2non This issue can be closed because it is fixed.