Raymond Hettinger <raymond.hettin...@gmail.com> added the comment:

This core of this idea is plausible.  It is a common problem for people to want 
to teach a class how to convert itself to and from JSON.

Altering the API for dicts is a major step, so you would need to take this to 
python-ideas to start getting buy-in.   A much smaller API change would be to 
just teach the JSON module to recognize a __json__ method.

Presumably if a robust serialization solution is created, people will need a 
way to deserialize back into a named tuple, data class, or custom class.  
Offhand, the only way I can think of to do this would be to add a field that 
could be recognized by json.load().  Some care would be needed to not create a 
pickle-like risk of arbitrary code execution.

----------

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

Reply via email to