Encoding NaN in JSON

Chris “Kwpolska” Warrick kwpolska at gmail.com
Fri Apr 19 14:21:49 EDT 2013


On Fri, Apr 19, 2013 at 4:54 PM, Grant Edwards <invalid at invalid.invalid> wrote:
> On 2013-04-18, Wayne Werner <wayne at waynewerner.com> wrote:
>> On Wed, 17 Apr 2013, Miki Tebeka wrote:
>>
>>>>> I'm trying to find a way to have json emit float('NaN') as 'N/A'.
>>>> No.  There is no way to represent NaN in JSON.  It's simply not part of the
>>>> specification.
>>> I know that. I'm trying to emit the *string* 'N/A' for every NaN.
>>
>> Why not use `null` instead? It seems to be semantically more similar...
>
> Why not use 'NaN' instead? It seems to be even more semantically
> similar...

Because there is no NaN in JSON?  Unless you mean a string, which
makes no semantical sense and is human-oriented and not
machine-oriented.

--
Kwpolska <http://kwpolska.tk> | GPG KEY: 5EAAEA16
stop html mail                | always bottom-post
http://asciiribbon.org        | http://caliburn.nl/topposting.html



More information about the Python-list mailing list