Closed nazariyv closed 4 years ago
IMO, there's nothing wrong with that:
field_name
defines how the attribute will be named on the outside world domain, and the attribute name defines the same inside your application logic domain. So if you're using it for both encoding and decoding, you want to keep consistency of that names in each domain.
If you need to reencode to json with different key names that in the decode input data, then you probably have two different domains that need to be modeled separately with different dataclasses.
expected:
actual:
would be nice to have a switch somewhere that allows us to use the attr name instead of the field_name. My current solution is an additional decorator that monkeypatches the to_dict function: