Bob Ippolito <b...@redivi.com> added the comment:

I would certainly reconsider it at this point, I think a bona fide ABC 
*specific to JSON encoding* would be a good way to do it. simplejson has two 
ways to do this, the `for_json` parameter which will use a `for_json()` method 
on any object as the JSON representation if present, and the 
`namedtuple_as_object` parameter which will do the same for objects with an 
`_asdict()` method. As part of the standard library it might make more sense to 
rename `for_json()` to `__json__()` or similar.

It is a bit unfortunate that you can't guarantee round-trip on deserialization, 
but that has always been the case. To get round-tripping (without tagging 
everything that has been encoded in some way like pickle does), you really 
should be working with a schema of some kind.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue34858>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to