It would be great to be able to handle serialization of non JSON serializable floats (the non-finites: inf, -inf, nan). Preferably, in a manner consistent with the existing mechanisms for serialization of non-JSON types -- the user-supplied default function.
Something like:
>>> simplejson.dumps(float('inf'), allow_nan=False, default=lambda x: {"$repr": repr(x)})
'{"$repr": "inf"}'
If you think this would be worthwhile, I'm willing to work on a pull request (I submitted a first draft Python-only implementation, let me know if you agree with the direction).
Btw, this issue is tangential to #149, which can be addressed similarly.
It would be great to be able to handle serialization of non JSON serializable floats (the non-finites:
inf,-inf,nan). Preferably, in a manner consistent with the existing mechanisms for serialization of non-JSON types -- the user-supplieddefaultfunction.Something like:
If you think this would be worthwhile, I'm willing to work on a pull request (I submitted a first draft Python-only implementation, let me know if you agree with the direction).
Btw, this issue is tangential to #149, which can be addressed similarly.