Support Decimal in PYSONEncoder

issue7291
review46341002
This commit is contained in:
Cédric Krier committed 2018-04-17 17:58:13 +02:00
1 parent c8896c1efb
commit 088627dcd2
1 file changed
+3
+3
View File
@@ -2,6 +2,7 @@
# this repository contains the full copyright notices and license terms.
import json
import datetime
from decimal import Decimal
from dateutil.relativedelta import relativedelta
from functools import reduce, wraps
@@ -117,6 +118,8 @@ class PYSONEncoder(json.JSONEncoder):
).pyson()
else:
return Date(obj.year, obj.month, obj.day).pyson()
elif isinstance(obj, Decimal):
return float(obj)
return super(PYSONEncoder, self).default(obj)