Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import json
import datetime
class DeepEncoder(json.JSONEncoder):
def default(self, obj):
if type(obj) in (datetime.datetime, datetime.date):
return obj.isoformat()
try:
return super(DeepEncoder, self).default(obj)
except TypeError, te:
return obj.__dict__
res = json.dumps(res_normalized, cls=DeepEncoder, **kwargs)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.