Serhiy Storchaka added the comment:

This could fix other issues:

* issue16535 -- for Decimal.
* issue20774 -- for deque.
* issue24313 -- for NumPy numeric types.
* issue26263 -- for array.

Currently the blessed way of JSON encoder customization is to implement the 
default method in JSONEncoder subclass or pass the default argument to dump(). 
But that requires changing every JSON serialization call and handling all 
non-standard types in one function. I think it would be handly to pick the 
type-specific serialization function from: 1) per-encoder dispatch table, 2) 
global dispatch type (registry), 3) __json__ method. This can be done after the 
default function fails or be included in the default default method.

This will add JSON support of standard library types (e.g. collections other 
than list, tuple and dict, numbers other than int and float) and will help to 
implement task specific serialization of user classes.

----------
nosy: +serhiy.storchaka
resolution: later -> 
stage: resolved -> needs patch
status: closed -> open
versions: +Python 3.7 -Python 3.6

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue27362>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to