You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
in default function, you expect that always we will need to validate the data o instance of type t.
but we might have cases where we also need to have more than type instance type validation, for example, in my case I want to serialize all dataclasses.dataclass to a dict using dataclasses.asdict.
So recommend adding the following enhancements to the register_type method .
def default(self, o):
reducer = getattr(o, "__json__", None)
if reducer is not None:
return reducer()
if isinstance(o, textual_types):
return str(o)
for t, (marker, encoder, validator) in _encoders.items():
if validator and validator(o):
return _as(marker, encoder(o))
if isinstance(o, t):
return _as(marker, encoder(o))
The text was updated successfully, but these errors were encountered:
in default function, you expect that always we will need to validate the data
o
instance of typet
.but we might have cases where we also need to have more than type instance type validation, for example, in my case I want to serialize all
dataclasses.dataclass
to adict
usingdataclasses.asdict
.So recommend adding the following enhancements to the register_type method .
The text was updated successfully, but these errors were encountered: