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.