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

add delete function #43

Closed LQBing closed 1 year ago

coveralls commented 4 years ago

Coverage Status

Coverage remained the same at 0.0% when pulling e79fc1033bfcd13103d0f66105b7f192e91f038b on LQBing:master into e5405c1adc9b90aa081595d4982833f6f2a2893a on h2non:master.

momocow commented 4 years ago

Hi, I just happened to see this PR and come up with a question.

How is delete() different from filter() given the filter function is lambda d: True?

>>> jsonpath_expr = parse("foo[*].baz")
>>> jsonpath_expr.filter(lambda d: True, {'foo': [{'baz': 1}, {'baz': 2}]})
{'foo': [{}, {}]}
LQBing commented 4 years ago

Verified

Hi, I just happened to see this PR and come up with a question.

How is delete() different from filter() given the filter function is lambda d: True?

>>> jsonpath_expr = parse("foo[*].baz")
>>> jsonpath_expr.filter(lambda d: True, {'foo': [{'baz': 1}, {'baz': 2}]})
{'foo': [{}, {}]}

I verified, no different between their result. But it is not easy to find this usage in the readme.md, and the delete or remove function is a common methods. Can you add the usage into the readme.md?

momocow commented 4 years ago

Can you add the usage into the readme.md?

Sorry but no, I'm not even the owner or a contributor of this repo, just someone trying to figure out how to do filtering with jsonpath.

But I think #44 may be useful to you.

michaelmior commented 1 year ago

I added some relevant examples to the README, so I think this can be closed. Feel free to comment if you're still having any issues.