Skip to content

Instantly share code, notes, and snippets.

@pilt
Created October 25, 2011 08:37
Show Gist options
  • Select an option

  • Save pilt/1311862 to your computer and use it in GitHub Desktop.

Select an option

Save pilt/1311862 to your computer and use it in GitHub Desktop.
class Foo(object):
def to_json(self):
return json.dumps(self, cls=MongoEncoder)
_json = functools.partial(json.dumps, cls=MongoEncoder) # _json([1,2,3]) -> '[1, 2, 3]'
class Foo(object):
to_json = _json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment