Joao S. O. Bueno wrote:
Short of a long term solution, like a __json__ protocol, or at least special
support in Python json module for objects of type "numbers.Number", the only way to go, is, as you are asking, being able to insert "raw strings into json".

No, that's not the only way. It would be sufficient just to add a
"use decimal" option to the stdlib json module.

Since Python's Decimal preserves all the information in the JSON
representation of a float (including trailing zeroes!), anything
else you might want can be achieved by pre/postprocessing the
decoded data structure.

It's just occurred to me that this isn't quite true, since
Decimal doesn't preserve *leading* zeroes. But an application
that cared about that would be pretty weird. So I think a
"use decimal" option would cover the vast majority of use
cases.

--
Greg
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/GBHJ7QXKQN5ZRHUKDYA52PHBUSOIJF4J/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to