10 Aug
2019
10 Aug
'19
2:09 a.m.
Andrew Barnert wrote:
No you can’t. Decimal accepts strings that aren’t valid as JSON numbers, like `.3`,
That's not a problem as long as it doesn't serialise them that way, which it wouldn't:
str(Decimal('.3')) '0.3'
or `nan`,
The serialiser could raise an exception in that case. BTW, I just checked what it does with floats:
json.dumps(float('nan')) 'NaN'
So it seems that it currently doesn't care about strict conformance here. -- Greg