h2non / jsonpath-ng

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

Fix issue with lambda based updates #101

Closed RemiRigal closed 9 months ago

RemiRigal commented 2 years ago

When performing an update with a lambda function, the lambda function is correctly detected and called but the returned value is not used.

Example:

import jsonpath_ng

expr = jsonpath_ng.parse("foo[*].baz")
d = {'foo': [{'baz': 1}, {'baz': 2}]}

d = expr.update(d, lambda x, y, z: x + 1)

The expected value for d is:

d = {'foo': [{'baz': 2}, {'baz': 3}]}

But values are not updated.

michaelmior commented 11 months ago

@RemiRigal Could you add a test for this case?

kurtmckee commented 9 months ago

This PR can be closed; @RemiRigal's changes were merged via #149.