Closed daiooo closed 5 years ago
You can use dataclasses.asdict
.
For anyone else who comes here looking for the same thing, here's an example:
>>> import dacite
>>> from dataclasses import dataclass, asdict
>>> @dataclass
... class A:
... a: int
...
>>> @dataclass
... class B:
... a: A
... b: int
>>> asdict(dacite.from_dict(B, {'a': { 'a': 1 }, 'b': 2}))
{'a': {'a': 1}, 'b': 2}
tks