[issue23123] Only READ support for Decimal in json

Raymond Hettinger report at bugs.python.org
Mon Dec 29 09:30:19 CET 2014


Raymond Hettinger added the comment:

> Given that json is multi-language format ... I don't know 
> that we can expect much more from it.

JSON specifies a textual number format but doesn't dictate whether that format represents a fixed precision binary float point number or a decimal floating point number.  It is perfectly reasonable for someone to want to read and write a JSON number format to and from a decimal (we also see this with database formats as well -- such as sqlite).

This bug report isn't a JSON spec issue; rather, it is about how the JSON module API can support (or inhibit) valid use cases.

AFAICT, the patch to make the API better support enums had the side-effect of inhibiting the APIs ability to support number objects that want to control their output via __str__ or __repr__.  This seems to block-off decimal support and support for controlling displayed precision.

I think the Enum patch is suspect and could be considered a regression.  That said, we could simply add direct support for decimals and leave the enum patch in-place (though it still impairs a user's ability to control the displayed precision).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23123>
_______________________________________


More information about the Python-bugs-list mailing list