pykson icon indicating copy to clipboard operation
pykson copied to clipboard

Failed to initialize variables in deeper inheritance level

Open patrickelectric opened this issue 4 years ago • 0 comments

class Class1(pykson.JsonObject):
    variable_1 = pykson.IntegerField(default_value=1)

class Class2(Class1):
    variable_2 = pykson.IntegerField(default_value=2)

class Class3(Class2):
    variable_3 = pykson.IntegerField(default_value=3)

class Class4(Class3):
    variable_4 = pykson.IntegerField(default_value=4)

class_4 = Class4()
print(Pykson().to_json(class_4))

The following code returns: {"variable_4": 4, "variable_3": 3, "variable_2": null, "variable_1": null}

patrickelectric avatar Jan 18 '22 21:01 patrickelectric