Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16850 -- Made sure we always represent Decimal instances with …

…JS strings when serializing.

We force this when calling simplejson dump() to isolate us from changes of
default behavior to encode them with JavaScript numbers instead that could
introduce loss of precision when decoding back from JSON to Python.

Thanks Raphael Hertzog for the report and Bob Ippolito for his help.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17228 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit b5d9ad982d8f28921d31f163e6d636a310a95922 1 parent e31c43a
Ramiro Morales authored December 17, 2011

Showing 1 changed file with 1 addition and 0 deletions. Show diff stats Hide diff stats

  1. 1  django/core/serializers/json.py
1  django/core/serializers/json.py
@@ -18,6 +18,7 @@ class Serializer(PythonSerializer):
18 18
     internal_use_only = False
19 19
 
20 20
     def end_serialization(self):
  21
+        self.options.update({'use_decimal': False}) # Use JS strings to represent Python Decimal instances (ticket #16850)
21 22
         simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
22 23
 
23 24
     def getvalue(self):

0 notes on commit b5d9ad9

Please sign in to comment.
Something went wrong with that request. Please try again.