simplejson: alternate encoder not called enought

Pierre Hanser hanser at
Sat Mar 21 22:11:32 CET 2009


I'm trying to use simplejson to encode some
python objects using simplejson dumps method.

The dumps method accept a cls parameter to specify
an alternate encoder. But it seems that this alternate
encoder is called only as a last resort, if object type
is not int, string, and all other basic types.

My problem is that i wanted to specify an encoding
for a dbus.Boolean object which inherits from int.

As int is handled by the standard encoder, the alternate
encoder is never called and a dbus.Boolean is converted
to 0 or 1 instead of true or false.

Could someone knowledgeabled enought confirm my diagnostic?
thanks in advance

More information about the Python-list mailing list