Forking simplejson

Terry Reedy tjreedy at udel.edu
Wed Oct 26 15:29:09 EDT 2011


On 10/26/2011 5:14 AM, Amirouche Boubekki wrote:
> Héllo,
>
> I would like to fork simplejson [1] and implement serialization rules
> based on protocols instead of types [2], plus special cases for protocol
> free objects, that breaks compatibility. The benefit will be a better
> API for json serialization of custom classes and in the case of iterable
> it will avoid a calls like:
>
>  >>> simplejson.dumps(list(my_iterable))
>
> The serialization of custom objects is documented in the class instead
> of the ``default`` function of current simplejson implementation [3].
>
> The encoding algorithm works with a priority list that is summarized in
> the next table:
>
> +-------------------+---------------+
> | Python protocol | JSON |
> | or special case | |
> +===================+===============+
> | (ø) __json__ | see (ø) |
> +-------------------+---------------|
>       | map               | object        |

I am curious what you mean by the 'map' protocol.

 > Where are documented the different protocols implemented by Python 
objects ?

Ref 3.3 special method names (and elsewhere ;-)
http://docs.python.org/py3k/reference/datamodel.html#special-method-names

---
Terry Jan Reedy





More information about the Python-list mailing list