#3324: MySQL + FloatField + JSON => broken
---------------------------+------------------------------------------------
Reporter: [EMAIL PROTECTED] | Owner: jacob
Status: new | Component: Serialization
Version: SVN | Keywords:
Stage: Unreviewed | Has_patch: 0
---------------------------+------------------------------------------------
when serializing objects from a MySQL DB containing FloatFields to JSON,
the float values are converted to Decimal objects, which are not
understood by simplejson:
{{{
Traceback (most recent call last):
File "blah/test.py", line 18, in ?
test()
File "blah/test.py", line 16, in test
print serialize("json", Blah.objects.all())
File "/home/alex/source/svn/django/django/core/serializers/__init__.py",
line 55, in serialize
s.serialize(queryset, **options)
File "/home/alex/source/svn/django/django/core/serializers/base.py",
line 49, in serialize
self.end_serialization()
File "/home/alex/source/svn/django/django/core/serializers/json.py",
line 19, in end_serialization
simplejson.dump(self.objects, self.stream,
cls=DateTimeAwareJSONEncoder, **self.options)
File "/home/alex/source/svn/django/django/utils/simplejson/__init__.py",
line 119, in dump
for chunk in iterable:
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 220, in _iterencode
for chunk in self._iterencode_list(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 143, in _iterencode_list
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 223, in _iterencode
for chunk in self._iterencode_dict(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 196, in _iterencode_dict
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 223, in _iterencode
for chunk in self._iterencode_dict(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 196, in _iterencode_dict
for chunk in self._iterencode(value, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 231, in _iterencode
for chunk in self._iterencode_default(o, markers):
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 237, in _iterencode_default
newobj = self.default(o)
File "/home/alex/source/svn/django/django/core/serializers/json.py",
line 51, in default
return super(DateTimeAwareJSONEncoder, self).default(o)
File "/home/alex/source/svn/django/django/utils/simplejson/encoder.py",
line 258, in default
raise TypeError("%r is not JSON serializable" % (o,))
TypeError: Decimal("9999999.99999999999999999999") is not JSON
serializable
}}}
--
Ticket URL: <http://code.djangoproject.com/ticket/3324>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Django
updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---