I can't find any info on how can I update original JSON message values with complex paths with different depths.
I tried the jsonpath
lib, but it's documentation is all about getting values, and not setting them.
For example I have the following JSON:
{"very":{"long":{"path":{"A":"1"}}},"other":{"path":{"even":{"deeper":{"B":"2"}}}}}
Two paths can be specified outside a function.
This one maps to "1"
:
very.long.path.A
And this one to "2"
:
other.path.even.deeper.B
jsonpath
can extract values from provided paths, but my goal is to modify them.
Something that allows the following would be ideal :
old_json = '{"very":{"long":{"path":{"A":"1"}}},"other":{"path":{"even":{"deeper":{"B":"2"}}}}}'
path = "other.path.even.deeper.B"
value = "100500"
new_json = jsonparser.update_value(old_json, path, value)
Is there a library that can provide such functionalities ?