Closed tbarkai closed 2 years ago
This code:
@dataclass class Sample: prop: str def unrelated_date_deserializer(obj: str, cls: type = datetime, **kwargs) -> datetime: return datetime.strptime(obj, '%Y') jsons.set_deserializer(unrelated_date_deserializer, datetime) json = {'prop': '1025'} print(jsons.load(json, Sample, strict=True))
Outputs:
Sample(prop=datetime.datetime(1025, 1, 1, 0, 0))
Shouldn't the str type annotation be used to decide whether to employ the deserializer or not?
str
Hi @tbarkai. You are right: this is flawed, a string is to be expected. I will work on a fix.
This code:
Outputs:
Shouldn't the
str
type annotation be used to decide whether to employ the deserializer or not?