I want to create a json that describes ,in a completely generic form ,a nested object. For example:
class A():
def __init__(self,x):
self.x = x
class B():
def __init__(self,a: 'A'):
self.a = a
class C():
def __init__(self,a: 'A'):
self.a = a
I want to create class A then transfer it to B and C and describe it all on json ans generate this structure automatically. A schematic example of the json file that I would like to write:
{
"A":{"x": 3},
"B":{"a": "A"},
"C":{"a": "A"},
}
The code should look like that:
tree = json.load(json_file)
print(tree.B.a)
print(tree.C.a)
How can I implement this in python?