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


Groups > comp.lang.python > #44104

Re: Encoding NaN in JSON

Path csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <wayne@waynewerner.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'string.': 0.05; 'json': 0.07; 'parser': 0.07; 'skip:` 10': 0.07; 'string': 0.09; 'ambiguity': 0.09; 'converted': 0.09; 'parsed': 0.09; 'semantic': 0.09; 'whichever': 0.09; 'api': 0.11; 'cc:addr:python-list': 0.11; "wouldn't": 0.14; 'chrome,': 0.16; 'delimit': 0.16; 'evaluates': 0.16; 'nan': 0.16; 'sense,': 0.16; 'wayne': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'obviously': 0.18; 'value.': 0.19; 'seems': 0.21; 'proposed': 0.22; 'cc:addr:python.org': 0.22; 'header:User- Agent:1': 0.23; 'skip:` 20': 0.24; 'string,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'sort': 0.25; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'chris': 0.29; 'asked': 0.31; 'object.': 0.31; 'proposing': 0.31; 'probably': 0.32; 'text': 0.33; 'fri,': 0.33; 'sense': 0.34; 'but': 0.35; 'implement': 0.38; 'easiest': 0.38; 'pm,': 0.38; 'most': 0.60; "you're": 0.61; 'back': 0.62; "you'll": 0.62; 'skip:\xe2 10': 0.65; 'to:addr:gmail.com': 0.65; 'between': 0.67; 'fact,': 0.69; '8bit%:43': 0.74; 'you:': 0.81; 'choices,': 0.84; 'communicate.': 0.84; '2013,': 0.91; 'edwards': 0.91; 'suffer': 0.93; '2013': 0.98
Date Mon, 22 Apr 2013 13:53:13 -0500 (CDT)
From Wayne Werner <wayne@waynewerner.com>
X-X-Sender wayne@gilgamesh
To Chris “Kwpolska” Warrick <kwpolska@gmail.com>
Subject Re: Encoding NaN in JSON
In-Reply-To <CAMw+j7J8_+Q0Wa=U8430X1zVzb8CRyOrP_Z+k8UnnMXm3wt07Q@mail.gmail.com>
References <bf3bf709-9cca-4488-a3c7-97b066bb2adf@googlegroups.com> <k4dsm8dea0gi3gf689p94el7gc6b1vk4bh@4ax.com> <c37a3b9c-6fe8-48aa-b703-9b4f922c3969@googlegroups.com> <mailman.770.1366293244.3114.python-list@python.org> <kkrlr4$brs$1@reader1.panix.com> <mailman.836.1366395732.3114.python-list@python.org> <kks6np$mvt$1@reader1.panix.com> <CAMw+j7J8_+Q0Wa=U8430X1zVzb8CRyOrP_Z+k8UnnMXm3wt07Q@mail.gmail.com>
User-Agent Alpine 2.02 (DEB 1266 2009-07-14)
MIME-Version 1.0
Content-Type MULTIPART/MIXED; BOUNDARY="8323329-448008287-1366656793=:3322"
Cc python-list@python.org
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.935.1366656809.3114.python-list@python.org> (permalink)
Lines 41
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366656809 news.xs4all.nl 2297 [2001:888:2000:d::a6]:37443
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:44104

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Sat, 20 Apr 2013, Chris “Kwpolska” Warrick wrote:

> On Fri, Apr 19, 2013 at 9:42 PM, Grant Edwards <invalid@invalid.invalid> wrote:
>> 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'?
>
> Not me, Wayne Werner proposed to use the JSON null value.  I parsed
> the backticks (`) used by him as a way to delimit it from text and not
> as a string.

That was, in fact, my intention. Though it seems to me that you'll have to 
suffer between some sort of ambiguity - in Chrome, at least, 
`Number(null)` evaluates to `0` instead of NaN. But `Number('Whatever')` 
evaluates to NaN. However, a JSON parser obviously wouldn't be able to 
make the semantic distinction, so I think you'll be left with whichever 
API makes the most sense to you:

     NaN maps to null

            or

     NaN maps to "NaN" (or any other string, really)


Obviously you're not limited to these particular choices, but they're 
probably the easiest to implement and communicate.

HTH,
-W

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