Encoding NaN in JSON
Tim Roberts
timr at probo.com
Wed Apr 17 01:38:52 EDT 2013
Miki Tebeka <miki.tebeka at gmail.com> wrote:
>
>I'm trying to find a way to have json emit float('NaN') as 'N/A'.
>I can't seem to find a way since NaN is a float, which means overriding "default" won't help.
>
>Any simple way to do this?
No. There is no way to represent NaN in JSON. It's simply not part of the
specification. From RFC 4627 section 2.4:
Numeric values that cannot be represented as sequences of digits
(such as Infinity and NaN) are not permitted.
--
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.
More information about the Python-list
mailing list