Upgraded included simplejson to 2.0.7.

Also changed importing logic to prefer a system-installed version of
simplejson (unless it's an earlier version that does not contian the C
speedups), then the json module from Python 2.6, then the version
shipped with Django.

Fixed #9266.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@9707 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick 2009-01-06 05:13:02 +00:00
parent 3b489b7742
commit a9c2f033cd
6 changed files with 725 additions and 715 deletions

View file

@ -162,11 +162,17 @@ For example::
json_serializer = serializers.get_serializer("json")()
json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
The Django source code includes the simplejson_ module. Be aware that if you're
serializing using that module directly, not all Django output can be passed
unmodified to simplejson. In particular, :ref:`lazy translation objects
<lazy-translations>` need a `special encoder`_ written for them. Something like
this will work::
The Django source code includes the simplejson_ module. However, if you're
using Python 2.6 (which includes a builtin version of the module), Django will
use the builtin ``json`` module automatically. If you have a system installed
version that includes the C-based speedup extension, or your system version is
more recent than the version shipped with Django (currently, 2.0.7), the
system version will be used instead of the version included with Django.
Be aware that if you're serializing using that module directly, not all Django
output can be passed unmodified to simplejson. In particular, :ref:`lazy
translation objects <lazy-translations>` need a `special encoder`_ written for
them. Something like this will work::
from django.utils.functional import Promise
from django.utils.encoding import force_unicode
@ -178,3 +184,4 @@ this will work::
return obj
.. _special encoder: http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.7/docs/index.html