Encoding NaN in JSON

Roland Koebler r.koebler at yahoo.de
Thu Apr 18 04:11:48 EDT 2013


On Thu, Apr 18, 2013 at 11:46:37AM +1000, Chris Angelico wrote:
> Wait... you can do that? It's internal to iterencode, at least in
> Python 3.3 and 2.7 that I'm looking at here.
In Python 2.6 it wasn't internal to iterencode; in Python 2.7 and 3.x
you probably would have to monkey-patch iterencode. (In addition, patching
floatstr alone wouldn't be enough in 3.x and probably 2.7, since you also
have to make sure that the C-extension is not used here.)

BUT: Keep in mind that monkey-patches are problematic, and should be
avoided (or used very carefully) in production code. So, better
replace the complete encoder.py or use your own patched version
of the complete json-module.

Roland



More information about the Python-list mailing list