pass decoder args

32 views
Skip to first unread message

JD

unread,
Jan 25, 2011, 4:09:48 PM1/25/11
to jsonpickle
hi, this is a great package and i've been getting a lot of use out of
it. just curious if there was a reason to include the ability to pass
arguments to the encoder - set_encoder_options() - but not to the
decoder. the example i'm running up against is that the mongodb
python api includes a custom encoder/decoder pair to pass through the
json serializer on the default/object_hook args, respectively.

this works great for encoding a custom object with BSON-specific
fields like ObjectId, e.g.

jsonpickle.set_encoder_options('json', default=bson.json_util.default)

but decoding the object becomes impossible to do through jsonpickle
since you can't pass through the object_hook argument.

appears to be a quick patch to include decoder options similar to the
encoder ones, and i'd be happy to contribute it unless there's a
reason for excluding it that i've overlooked.

-john

David Aguilar

unread,
Jan 28, 2011, 12:21:27 AM1/28/11
to JD, jsonp...@googlegroups.com

thanks JD, this seems like a good thing in general.
it'd be really nice to include mongodb as a thirdparty test
or recipe/example in the documentation ;-)
--
David

Reply all
Reply to author
Forward
0 new messages