Let's say I have a simple json variable and I can access it's values like this:
import json
# some JSON:
x = '{ "name":"John", "age":30, "city":"New York", "ID_info":{ "first_name":"John", "year":1995}}'
# parse x:
y = json.loads(x)
# the result is a Python dictionary:
print(y["age"]) #prints 30
print(y["ID_info"]["first_name"]) #prints John
Is there a way to replace the value in "first_name" so that it finds it in "name"?
I would expect something like:
import json
# some JSON:
x = '{ "name":"John", "age":30, "city":"New York", "ID_info":{ "first_name":$Ref("name"), "year":1995}}'
# parse x:
y = json.loads(x)
# the result is a Python dictionary:
print(y["age"]) #prints 30
print(y["ID_info"]["first_name"]) # I'd like it to print "John"
PS this is a simple example IRL I have nested jsons I want to simplify :)