dataclasses-json
dataclasses-json copied to clipboard
Support usage of a custom encoder on nested dataclasses
Currently, if we use a custom encoder on a nested dataclass, it is not called during serialization.
This pull request fixes it, with associated test cases.
As my use case was to strip None values at serialization, I was wondering if this was a common enough use case to add a boolean flag in the dataclass_json configuration to avoid writing a custom Encoder:
def dataclass_json(_cls=None, *, letter_case=None,
undefined: Optional[Union[str, Undefined]] = None,
skip_none: Optional[bool] = None):
If that's the case, I shall add this case to the config and see from there how to use the cls.dataclass_json_config at serialization time
Hi @whisust, thanks for the contribution. Please update to match newest version on master and resolve conflicts, then we can proceed with a review