dataclass-wizard icon indicating copy to clipboard operation
dataclass-wizard copied to clipboard

Override Conversion for ObjectId when using asDict()

Open Bewinxed opened this issue 3 years ago • 1 comments

Description

I'm trying to serialize a custom class, in which an _id field is an ObjectId() instance for use in MongoDB

However, when I serialize it using asDict() it converts it to a string

How can I override this behavior recursively for any item of that class to skip conversion?

Bewinxed avatar May 01 '22 03:05 Bewinxed

Hi @Bewinxed, thanks again for opening this issue. Can you provide a code example of how you are trying to de/serialize the custom class currently?

Although I do agree, supporting custom classes in the de/serialization process - i.e. that are not dataclasses, I feel is an important goal to have.

rnag avatar May 01 '22 16:05 rnag