On Sat, 20 Apr 2013, Chris “Kwpolska” Warrick wrote:
On Fri, Apr 19, 2013 at 9:42 PM, Grant Edwards 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
On Fri, Apr 19, 2013 at 9:42 PM, Grant Edwards 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 proposi
> > You understand that this will result in a chunk of text that is not JSON?
> I think he means something like this:
> >>> json.dumps([float('nan')])
> '["N/A"]'
That's exactly what I mean :)
--
http://mail.python.org/mailman/listinfo/python-list
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
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
sp
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* '
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 un
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
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? I
On Thu, Apr 18, 2013 at 11:46:37AM +1000, Chris Angelico wrote:
> 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.
In Python 2.6 it wasn't internal to iterencode; in Python 2.7 and 3.x
you probably would have to monkey-patch iterencode
On Thu, Apr 18, 2013 at 11:39 AM, Roland Koebler 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 loo
On Thu, Apr 18, 2013 at 11:01 AM, Miki Tebeka wrote:
> [Roland]
>> yes, there is: subclass+extend the JSON-encoder, see pydoc json.
> Please read the original post before answering. What you suggested does not
> work since NaN is of float type.
You may be able to override a bit more of the code,
Hi,
> > yes, there is: subclass+extend the JSON-encoder, see pydoc json.
> Please read the original post before answering. What you suggested does not
> work since NaN is of float type.
ok, right, default does not work this way.
But I would still suggest to extend the JSON-encoder, since that is
[Roland]
> yes, there is: subclass+extend the JSON-encoder, see pydoc json.
Please read the original post before answering. What you suggested does not
work since NaN is of float type.
--
http://mail.python.org/mailman/listinfo/python-list
Hi,
> > Easiest way is probably to transform your object before you try to write
> Yeah, that's what I ended up doing. Wondered if there's a better way ...
yes, there is: subclass+extend the JSON-encoder, see pydoc json.
e.g.:
class JsonNanEncoder(json.JSONEncoder):
def default(self, obj):
On 04/17/2013 03:05 PM, Johann Hibschman wrote:
Miki Tebeka writes:
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.
> >>> I'm trying to find a way to have json emit float('NaN') as 'N/A'.
> Easiest way is probably to transform your object before you try to write
Yeah, that's what I ended up doing. Wondered if there's a better way ...
Thanks,
--
Miki
--
http://mail.python.org/mailman/listinfo/python-list
Miki Tebeka writes:
>>> 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.
Easiest way is probably to transform your
In Miki Tebeka
writes:
> >> 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.
import math
x = possibly_NaN()
>> 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.
--
http://mail.python.org/mailman/listinfo/python-list
Miki Tebeka wrote:
>
>I'm trying to find a way to have json emit float('NaN') as 'N/A'.
>I can't seem to find a way since NaN is a float, which means overriding
>"default" won't help.
>
>Any simple way to do this?
No. There is no way to represent NaN in JSON. It's simply not part of the
specif
Greetings,
I'm trying to find a way to have json emit float('NaN') as 'N/A'.
I can't seem to find a way since NaN is a float, which means overriding
"default" won't help.
Any simple way to do this?
Thanks,
--
Miki
--
http://mail.python.org/mailman/listinfo/python-list
22 matches
Mail list logo