summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIuri de Silvio <iurisilvio@gmail.com>2016-12-18 19:10:18 -0200
committerGitHub <noreply@github.com>2016-12-18 19:10:18 -0200
commitddc4bd30f22e40ae4e3aa9347747f1f96912191a (patch)
tree536a59a436a1800a63baee129ec166468d8db97b
parent52e547daf9ae120b6e07331e8c5791bb88f911c6 (diff)
parent9fdb72cc5c69138d19c969d9cef91c5f60cd6bd0 (diff)
downloadtablib-ddc4bd30f22e40ae4e3aa9347747f1f96912191a.tar.gz
Merge pull request #234 from BrianPainter/master
if the object is a decimal, return the string representation of it.
-rw-r--r--tablib/formats/_json.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/tablib/formats/_json.py b/tablib/formats/_json.py
index fb66745..72c3d02 100644
--- a/tablib/formats/_json.py
+++ b/tablib/formats/_json.py
@@ -2,6 +2,7 @@
""" Tablib - JSON Support
"""
+import decimal
import tablib
@@ -16,7 +17,13 @@ extensions = ('json', 'jsn')
def date_handler(obj):
- return obj.isoformat() if hasattr(obj, 'isoformat') else obj
+ if isinstance(obj, decimal.Decimal):
+ return str(obj)
+ elif hasattr(obj, 'isoformat'):
+ return obj.isoformat()
+ else:
+ return obj
+ # return obj.isoformat() if hasattr(obj, 'isoformat') else obj
def export_set(dataset):