Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43886

Re: Encoding NaN in JSON

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 <python-python-list@m.gmane.org>
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 <robert.kern@gmail.com>
Subject Re: Encoding NaN in JSON
Date Fri, 19 Apr 2013 11:43:26 +0530
References <bf3bf709-9cca-4488-a3c7-97b066bb2adf@googlegroups.com> <k4dsm8dea0gi3gf689p94el7gc6b1vk4bh@4ax.com> <c37a3b9c-6fe8-48aa-b703-9b4f922c3969@googlegroups.com> <n1k1n8t0gsuv0dvt6amllmn6u0vmng4jnf@4ax.com>
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 <n1k1n8t0gsuv0dvt6amllmn6u0vmng4jnf@4ax.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.813.1366352020.3114.python-list@python.org> (permalink)
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

Show key headers only | View raw


On 2013-04-19 10:34, Tim Roberts wrote:
> Miki Tebeka <miki.tebeka@gmail.com> 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Encoding NaN in JSON Miki Tebeka <miki.tebeka@gmail.com> - 2013-04-16 17:21 -0700
  Re: Encoding NaN in JSON Tim Roberts <timr@probo.com> - 2013-04-16 22:38 -0700
    Re: Encoding NaN in JSON Miki Tebeka <miki.tebeka@gmail.com> - 2013-04-17 07:33 -0700
      Re: Encoding NaN in JSON John Gordon <gordon@panix.com> - 2013-04-17 14:47 +0000
      Re: Encoding NaN in JSON Johann Hibschman <jhibschman@gmail.com> - 2013-04-17 14:05 -0500
        Re: Encoding NaN in JSON Miki Tebeka <miki.tebeka@gmail.com> - 2013-04-17 14:21 -0700
          Re: Encoding NaN in JSON Roland Koebler <r.koebler@yahoo.de> - 2013-04-18 00:40 +0200
            Re: Encoding NaN in JSON Miki Tebeka <miki.tebeka@gmail.com> - 2013-04-17 18:01 -0700
              Re: Encoding NaN in JSON Roland Koebler <r.koebler@yahoo.de> - 2013-04-18 03:39 +0200
              Re: Encoding NaN in JSON Chris Angelico <rosuav@gmail.com> - 2013-04-18 11:41 +1000
              Re: Encoding NaN in JSON Chris Angelico <rosuav@gmail.com> - 2013-04-18 11:46 +1000
              Re: Encoding NaN in JSON Roland Koebler <r.koebler@yahoo.de> - 2013-04-18 10:11 +0200
        Re: Encoding NaN in JSON Dave Angel <d@davea.name> - 2013-04-17 17:37 -0400
      Re: Encoding NaN in JSON Wayne Werner <wayne@waynewerner.com> - 2013-04-18 08:53 -0500
        Re: Encoding NaN in JSON Grant Edwards <invalid@invalid.invalid> - 2013-04-19 14:54 +0000
          Re: Encoding NaN in JSON Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-19 20:21 +0200
            Re: Encoding NaN in JSON Grant Edwards <invalid@invalid.invalid> - 2013-04-19 19:42 +0000
              Re: Encoding NaN in JSON Chris “Kwpolska” Warrick <kwpolska@gmail.com> - 2013-04-20 10:00 +0200
              Re: Encoding NaN in JSON Wayne Werner <wayne@waynewerner.com> - 2013-04-22 13:53 -0500
      Re: Encoding NaN in JSON Tim Roberts <timr@probo.com> - 2013-04-18 22:04 -0700
        Re: Encoding NaN in JSON Robert Kern <robert.kern@gmail.com> - 2013-04-19 11:43 +0530
          Re: Encoding NaN in JSON Miki Tebeka <miki.tebeka@gmail.com> - 2013-04-19 12:52 -0700

csiph-web