lidatong / dataclasses-json

Easily serialize Data Classes to and from JSON
MIT License
1.38k stars 154 forks source link

recursively ignoring fields that are not json serializable? #259

Open li-dennis opened 4 years ago

li-dennis commented 4 years ago

Hi,

I'm using a few libraries that aren't readily JSON Serializable, and rather than attempt to write a serializer for every time it shows up, I rather just ignore it. Is there a simple way to do this? I can't seem to find anything in the documents that addresses this.

Best

matt035343 commented 1 year ago

Hi there.

Could you do something like this?

@dataclass
class EncodeExclude(DataClassJsonMixin):
    some_field: str
    ignored_field: str = field(metadata=config(exclude=Exclude.ALWAYS))