Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support usage of a custom encoder on nested dataclasses #164

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

whisust
Copy link

@whisust whisust commented Jan 6, 2020

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

@matt035343
Copy link
Collaborator

Hi @whisust, thanks for the contribution. Please update to match newest version on master and resolve conflicts, then we can proceed with a review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants