Skip to content

Commit f4cde00

Browse files
authored
Merge pull request #169 from dxmo/add_decimal_support
Added support for Decimal type in JSON encoder
2 parents 0c84187 + 32fa5e8 commit f4cde00

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

flask_rest_jsonapi/utils.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import json
44
from uuid import UUID
55
from datetime import datetime
6+
from decimal import Decimal
67

78

89
class JSONEncoder(json.JSONEncoder):
@@ -11,4 +12,6 @@ def default(self, obj):
1112
return obj.isoformat()
1213
elif isinstance(obj, UUID):
1314
return str(obj)
15+
elif isinstance(obj, Decimal):
16+
return str(obj)
1417
return json.JSONEncoder.default(self, obj)

0 commit comments

Comments
 (0)