[issue27362] json.dumps to check for obj.__json__ before raising TypeError

Daniel Ward report at bugs.python.org
Tue Jun 21 10:47:30 EDT 2016


Daniel Ward added the comment:

I don't think I explained the response very well, effectively the __json__ call would return an object which is JSON-serializable. This would include dict objects containing JSON-serializable objects albeit natively-supporting JSON serialisation or by means of subsequent obj.__json__ calls.

The reason I gave it __json__ is purely for easily-remembered implementation, separating it out from calls which may potentially clash with existing codebases, because let's face it, people don't often get to start again ;)

I'm not adverse to changing the method name at all, but I do believe this is a progressive way to go regarding JSON-serialization.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27362>
_______________________________________


More information about the Python-bugs-list mailing list