-
-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Description
Hello,
When I need to json encode a new object or an Enum , I need to either extend str, or build a json decoder to make it compatible with the default json encoder.
When using third parties lib, it might create some difficulties as implementing string is not an option, and the dumps method is not reachable.
If I wanted to do that in java, I would implement in my class a serialize method that would be called by json serializer.
Would it be possible, in the encoder, to allow the usage of either a serialize(self) method, or to directly use repr or str when the object after all other option failed.
Line 192 in a34e4db
| if isinstance(o, str): |
That will give the final developer a reliable way to explain the json encoder how to interpret the object and serialize it.