[issue36841] Supporting customization of float encoding in JSON

2021-09-30 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2021-09-30 Thread Min RK


Min RK  added the comment:

We just ran into this in Jupyter where we've removed a pre-processing step for 
data structures passed to json.dumps, which took care of this, but was 
expensive https://github.com/jupyter/jupyter_client/pull/706

My expectation was that our `default` would be called for the unsupported 
value, but it isn't. I see the PR proposes a new option, but would it be 
sensible to use the already-existing `default` callback for this? It seems like 
what `default` is for.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2021-09-30 Thread Min RK


Change by Min RK :


--
nosy: +minrk
nosy_count: 5.0 -> 6.0
pull_requests: +27016
pull_request: https://github.com/python/cpython/pull/28648

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2021-05-10 Thread Éric Araujo

Éric Araujo  added the comment:

I think this should be discussed on the mailing list or Discourse, to get use 
cases and needs.

--
nosy: +eric.araujo
versions: +Python 3.11 -Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-13 Thread Wei Lee


Wei Lee  added the comment:

I've sent a PR for it.
https://github.com/python/cpython/pull/13233

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-09 Thread Wei Lee


Change by Wei Lee :


--
keywords: +patch
pull_requests: +13143
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-08 Thread Mitar


Mitar  added the comment:

That would be awesome!

BTW, just as an additional example, JavaScrpt's JSON.stringify encodes NaN and 
Infinity to null. By having a custom function I could for example try to match 
such implementation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-08 Thread Wei Lee


Wei Lee  added the comment:

If no one is working on it, I'd like to give it a try.

--
nosy: +Lee-W

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-07 Thread SilentGhost


Change by SilentGhost :


--
nosy: +ezio.melotti, rhettinger
type:  -> enhancement
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36841] Supporting customization of float encoding in JSON

2019-05-07 Thread Mitar


New submission from Mitar :

Currently, there is only one argument which allows customization how float 
numbers are encoded in JSON: allow_nan. But this does not allow one to hook 
into the encoding of floating points really. The JSONEncoder is not called for 
float numbers.

The motivation here is that we would like to encode NaN and Infinity values 
differently, instead of non-standard approach and instead of raising an 
exception.

The "load" counterpart has "parse_float" which one can use to hook into parsing 
floats. I would suggest something similar, maybe "encode_float" which if 
provided would be used instead of the default.

--
components: Library (Lib)
messages: 341817
nosy: mitar
priority: normal
severity: normal
status: open
title: Supporting customization of float encoding in JSON

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com