[issue36841] Supporting customization of float encoding in JSON

Mitar report at bugs.python.org
Tue May 7 16:32:33 EDT 2019


New submission from Mitar <mmitar at gmail.com>:

Currently, there is only one argument which allows customization how float numbers are encoded in JSON: allow_nan. But this does not allow one to hook into the encoding of floating points really. The JSONEncoder is not called for float numbers.

The motivation here is that we would like to encode NaN and Infinity values differently, instead of non-standard approach and instead of raising an exception.

The "load" counterpart has "parse_float" which one can use to hook into parsing floats. I would suggest something similar, maybe "encode_float" which if provided would be used instead of the default.

----------
components: Library (Lib)
messages: 341817
nosy: mitar
priority: normal
severity: normal
status: open
title: Supporting customization of float encoding in JSON

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36841>
_______________________________________


More information about the Python-bugs-list mailing list