[Python-ideas] Serialization of custom classes.

Masklinn masklinn at masklinn.net
Wed Mar 30 13:17:48 CEST 2011

On 2011-03-30, at 13:07 , Jakob Bowyer wrote:
> Ignore customjsondumps for now. Im more getting at __json__ being a
> class method?

As I said, there is a blessed extension mechanism in subclassing JSONEncoder, and as long as all JSONEncoder subclasses correctly call super() they should be composable.

And if you decide that your objects will all implement __json__ you can just throw in a generic JSONEncoder for that.

What significant gain would an additional __json__ hook provide over it?

PS: the simplejson mailing list may be a better suggestion for that kind of things, it's probably where the tip of the development happens.

More information about the Python-ideas mailing list