[issue40475] json.JSONEncoder override default method

Karthikeyan Singaravelan report at bugs.python.org
Sat May 2 00:56:33 EDT 2020


Karthikeyan Singaravelan <tir.karthi at gmail.com> added the comment:

https://docs.python.org/3/library/json.html#json.JSONEncoder

> To extend this to recognize other objects, subclass and implement a default() method with another method that returns a serializable object for o if possible, otherwise it should call the superclass implementation (to raise TypeError).

default is called only when the object cannot be serialized by default. In this case dict is serializable and default won't be called.

----------
nosy: +ezio.melotti, rhettinger, xtreak

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40475>
_______________________________________


More information about the Python-bugs-list mailing list