Skip to content

Instantly share code, notes, and snippets.

@squishybear-zz
Created April 23, 2013 19:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save squishybear-zz/5446582 to your computer and use it in GitHub Desktop.
Save squishybear-zz/5446582 to your computer and use it in GitHub Desktop.
Try to override the DjangoJSONEncoder.
from django.core.serializers import json
class MyClass(json.DjangoJSONEncoder):
def default(self, o):
return o + 5
json.dumps([1, 2, 3], cls=MyClass)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment