Merge pull request #1107 from dpretty/master

Let JSONEncoder handle Numpy data types.
This commit is contained in:
Tom Christie 2013-09-13 11:42:15 -07:00
commit 36bd4f22a7

View File

@ -42,6 +42,8 @@ class JSONEncoder(json.JSONEncoder):
return str(o.total_seconds())
elif isinstance(o, decimal.Decimal):
return str(o)
elif hasattr(o, 'tolist'):
return o.tolist()
elif hasattr(o, '__iter__'):
return [i for i in o]
return super(JSONEncoder, self).default(o)