diff options
| author | Brian Painter <brianpainter@tindallcorp.com> | 2016-03-23 08:21:36 -0400 |
|---|---|---|
| committer | Brian Painter <brianpainter@tindallcorp.com> | 2016-03-23 08:21:36 -0400 |
| commit | 9fdb72cc5c69138d19c969d9cef91c5f60cd6bd0 (patch) | |
| tree | 12ad1ae9feb3f8a6440768cbd16dc160afcd6cb9 | |
| parent | a5b1f7987e3dd41a32e7e9d58389af2f80f21291 (diff) | |
| download | tablib-9fdb72cc5c69138d19c969d9cef91c5f60cd6bd0.tar.gz | |
if the object is a decimal, return the string representation of it.
| -rw-r--r-- | tablib/formats/_json.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/tablib/formats/_json.py b/tablib/formats/_json.py index 777040a..d063d10 100644 --- a/tablib/formats/_json.py +++ b/tablib/formats/_json.py @@ -2,6 +2,7 @@ """ Tablib - JSON Support """ +import decimal import tablib @@ -14,7 +15,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): |
