Created
April 3, 2014 19:31
-
-
Save darrellsilver/9961183 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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