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
Class members typed as 'Any' will have their value serialized using default_object_serializer(). This produces wrong results for dict objects. For example:
from typing import Any, Dict
import jsons
# BadClass will fail to serialize properly.
class BadClass:
key: str
value: Any # This is the problem.
bc = BadClass()
bc.key = "bad"
bc.value = {"a": "b", "c": "d", "e": "f"}
print(jsons.dumps(bc))
# GoodClass will work as expected.
class GoodClass:
key: str
value: Dict[str, Any]
gc = GoodClass()
gc.key = "good"
gc.value = {"a": "b", "c": "d", "e": "f"}
print(jsons.dumps(gc))
Class members typed as 'Any' will have their value serialized using default_object_serializer(). This produces wrong results for dict objects. For example:
The expected result:
The actual result:
Perhaps Any-types (as well as union types?) should be special cases and infer the serializer from the actual value?
The text was updated successfully, but these errors were encountered: