Skip to content

Ability to change values #21

@rolfn

Description

@rolfn
import jsonpath_rfc9535 as jsonpath

data = { 'foo':{ 'bar': { 'baz': 42 } } }

node = jsonpath.find_one('$.foo.bar.baz', data)

print(node.value)# --> 42
print(data['foo']['bar']['baz'])# --> 42

node.value = 99

print(node.value)# --> 99
print(data['foo']['bar']['baz'])# Wish that it were 99

Reading values ​​is pleasantly simple. It would be great if writing values ​​could be just as easy. Ideally, one could simply write

node.value = 99

This would then update both "node.value" and "data['foo']['bar']['baz']" with the new value. Other syntax options would also be acceptable. Another useful addition would be "node.parent", allowing for calls like

node.parent['baz']

to be used. I prefer "jsonpath_rfc9535" because of its good syntax compatibility with the JSONpath standard.

Thank you for your helpful work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions