[issue40475] json.JSONEncoder override default method

2020-05-01 Thread xie
xie added the comment: I got it,Thank you! -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker ___ _

[issue40475] json.JSONEncoder override default method

2020-05-01 Thread Karthikeyan Singaravelan
Karthikeyan Singaravelan 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 ca

[issue40475] json.JSONEncoder override default method

2020-05-01 Thread xie
New submission from xie : I see an example from here:https://docs.python.org/3/library/json.html --It is about custom method from python object to json string:- import json class ComplexEncoder(json.JSONEncoder): def default(self, obj): print("hi") if isinstance(obj,