New JSON encoding method proposal for custom objects
Denis McMahon
denismfmcmahon at gmail.com
Sun Nov 29 15:40:31 EST 2015
On Sun, 29 Nov 2015 07:05:30 -0800, cescus92 wrote:
> In this day I stumbled upon a very simple task: I had a list of
> instances of a custom class and I had to convert i into a JSON.
That's all well and good, but firstly you need to both dumps and loads to
work properly with json, and secondly there's no mechanism in json that
tells you what class of object you have.
So you may have a __json_dumps__ that will dump your object out to a json
string representation, but then how does json.loads recognise that it's
loading your object to call your object's __json_loads__?
--
Denis McMahon, denismfmcmahon at gmail.com
More information about the Python-list
mailing list