Ticket #3324: 3324_Decimal_is_not_JSON_serializable.diff
File 3324_Decimal_is_not_JSON_serializable.diff, 776 bytes (added by , 18 years ago) |
---|
-
django/utils/simplejson/encoder.py
2 2 Implementation of JSONEncoder 3 3 """ 4 4 import re 5 from decimal import Decimal 5 6 6 7 ESCAPE = re.compile(r'[\x00-\x19\\"\b\f\n\r\t]') 7 8 ESCAPE_ASCII = re.compile(r'([\\"/]|[^\ -~])') … … 256 257 yield 'false' 257 258 elif isinstance(o, (int, long)): 258 259 yield str(o) 259 elif isinstance(o, float) :260 elif isinstance(o, float) or isinstance(o, Decimal): 260 261 yield floatstr(o, self.allow_nan) 261 262 elif isinstance(o, (list, tuple)): 262 263 for chunk in self._iterencode_list(o, markers):