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


Groups > comp.lang.python > #43797

Re: Encoding NaN in JSON

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'that?': 0.05; 'override': 0.09; 'received:mail-vc0-f174.google.com': 0.09; 'wrapper': 0.09; 'python': 0.11; '2.7': 0.14; '"n/a"': 0.16; 'emits': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'nan': 0.16; 'wrote:': 0.18; 'looked': 0.18; 'bit': 0.19; 'thu,': 0.19; 'please?': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'patch': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'code': 0.31; 'received:209.85.220.174': 0.31; "i'd": 0.34; 'could': 0.34; 'received:209.85': 0.35; 'possible.': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'skip:j 20': 0.36; 'that!': 0.36; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'even': 0.60; 'first': 0.61; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=ImP6hfxj175OZ7TAOMEIdgd0uUEnqJvDjNot7Hf1iM4=; b=YZpgutbuMc1Zo+paEnhtJn6SdGDkzFcpiasDTsZyawb6QLZXg0zI3mNujSCI3kawbg Qj/RIJdv22Zc+utBLkiGkgcJtyIUePUindmd4i47eQyPSJoTMl01CyFC072iBB5Vjei8 rAHCnBfk47Br9iK9V5N4C6ENZeLwGwt38zMyy2KgXHUuGYz/nhzf7pP9LHoXlmso8y11 zqBgtdRMCJMvNqNHQbu1Z4uL5FUwPhrGZdChPxFIfVEpf7qhJtXWtxKHwKc/v60F5FOc hZsDiFtEO1E9Yn8F/GALvqALkYpa/2nVG9F9aPWmjL8z3gVltJ+aP1sIC8lE1AsZsjQq Pqxg==
MIME-Version 1.0
X-Received by 10.52.37.109 with SMTP id x13mr5898066vdj.10.1366249597473; Wed, 17 Apr 2013 18:46:37 -0700 (PDT)
In-Reply-To <20130418013938.GB28906@localhost>
References <20130417224030.GA28906@localhost> <1040891b-d350-4304-8112-de4a383562dc@googlegroups.com> <20130418013938.GB28906@localhost>
Date Thu, 18 Apr 2013 11:46:37 +1000
Subject Re: Encoding NaN in JSON
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
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.748.1366249600.3114.python-list@python.org> (permalink)
Lines 12
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1366249600 news.xs4all.nl 2176 [2001:888:2000:d::a6]:35589
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:43797

Show key headers only | View raw


On Thu, Apr 18, 2013 at 11:39 AM, Roland Koebler <r.koebler@yahoo.de> wrote:
> as a quickhack, you
> could even monkey patch json.encoder.floatstr with a wrapper which
> returns "N/A" for NaN. (I've tested it: It works.)

Wait... you can do that? It's internal to iterencode, at least in
Python 3.3 and 2.7 that I'm looking at here. Can you share your code
please? I'd like to try that! When I first looked at the docstring, I
was thinking "Ah, can I override the bit that emits NaN to return
\"N/A\" instead?", but the code made me think that's not possible.

ChrisA

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