Open aecay opened 4 years ago
Here's a test program:
import jsons from dataclasses import dataclass @dataclass class Animal: name: str @dataclass class Dog(Animal): pass @dataclass class Person(Animal): pet: Animal dave = Person(name="dave", pet=Dog(name="fido")) print(jsons.load(jsons.dump([dave], verbose=True))) print(jsons.load(jsons.dump(dave, verbose=True)))
Here's the output:
[Person(name='dave', pet=Animal(name='fido'))] Person(name='dave', pet=Dog(name='fido'))
When we round-trip the list through jsons, the info that Dave's pet is a dog (as opposed to a generic Animal) is lost.
Thanks @aecay for reporting this and for your pull request. I'll look into it in more detail as soon as I have the time. :-)
Here's a test program:
Here's the output:
When we round-trip the list through jsons, the info that Dave's pet is a dog (as opposed to a generic Animal) is lost.