[issue18264] enum.IntEnum is not compatible with JSON serialisation
Ethan Furman
report at bugs.python.org
Fri Jun 21 19:35:59 CEST 2013
Ethan Furman added the comment:
I'd be in favor of the __protocol__ route first and the PEP 443 route second.
The problem with just tacking in `str(int(value))` or `str(float(value))` is where does it stop? StrEnum, TupleEnum, BytesEnum, ComplexEnum, SomeOtherInterestingConstantEnum, etc., etc..
If we go the __protocol__ route we add one method to Enum which returns the `str` of its `.value`, and we're set for every Enum.* As a bonus, any other object that needs special json (or yaml or whatever) consideration has a fairly easy way to make it happen.
*Every normal Enum, anyway. ;)
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18264>
_______________________________________
More information about the Python-bugs-list
mailing list