Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.019 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'json': 0.07; 'chunk': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'emit': 0.16; 'kern': 0.16; 'nan': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'underlying': 0.16; 'wrote:': 0.18; 'trying': 0.19; '>>>': 0.22; 'header:User-Agent:1': 0.23; 'interpret': 0.24; 'this:': 0.26; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'tim': 0.29; 'robert': 0.30; "i'm": 0.30; 'that.': 0.31; '>>>>': 0.31; 'text': 0.33; 'something': 0.35; 'there': 0.35; 'skip:j 20': 0.36; 'represent': 0.38; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'read': 0.60; 'no.': 0.61; 'simply': 0.61; 'our': 0.64; 'world': 0.66; 'believe': 0.68; 'readers': 0.68; 'eco': 0.84; 'received:125': 0.84; 'terrible': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Robert Kern Subject: Re: Encoding NaN in JSON Date: Fri, 19 Apr 2013 11:43:26 +0530 References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 125.21.252.133 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:17.0) Gecko/20130328 Thunderbird/17.0.5 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 29 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1366352020 news.xs4all.nl 2180 [2001:888:2000:d::a6]:40864 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:43886 On 2013-04-19 10:34, Tim Roberts wrote: > 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. > > You understand that this will result in a chunk of text that is not JSON? > Other JSON readers won't be able to read it. I think he means something like this: >>> json.dumps([float('nan')]) '["N/A"]' Not '[N/A]' -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco