Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!transit3.readnews.com!nx01.iad01.newshosting.com!newshosting.com!news-out.readnews.com!transit4.readnews.com!panix!not-for-mail From: Grant Edwards Newsgroups: comp.lang.python Subject: Re: Encoding NaN in JSON Date: Fri, 19 Apr 2013 19:42:49 +0000 (UTC) Organization: PANIX Public Access Internet and UNIX, NYC Lines: 30 Message-ID: References: NNTP-Posting-Host: dsl.comtrol.com X-Trace: reader1.panix.com 1366400569 23549 64.122.56.22 (19 Apr 2013 19:42:49 GMT) X-Complaints-To: abuse@panix.com NNTP-Posting-Date: Fri, 19 Apr 2013 19:42:49 +0000 (UTC) User-Agent: slrn/1.0.1 (Linux) Xref: csiph.com comp.lang.python:43933 On 2013-04-19, Chris ???Kwpolska??? Warrick wrote: > On Fri, Apr 19, 2013 at 4:54 PM, Grant Edwards wrote: >> On 2013-04-18, Wayne Werner 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. The OP asked for a string, and I thought you were proposing the string 'null'. If one is to use a string, then 'NaN' makes the most sense, since it can be converted back into a floating point NaN object. I infer that you were proposing a JSON null value and not the string 'null'? -- Grant Edwards grant.b.edwards Yow! I'm receiving a coded at message from EUBIE BLAKE!! gmail.com