diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-04-29 19:58:00 +0200 |
|---|---|---|
| committer | Aymeric Augustin <aymeric.augustin@m4x.org> | 2012-04-29 19:58:00 +0200 |
| commit | cec6bd5a59547dc97fe98975c570fc27a1e970be (patch) | |
| tree | d084ff2008e4bba125c4b28297d6469992f2ec95 /docs/topics | |
| parent | ee0a7c741e98214bac7eeb60b848cf099ff28836 (diff) | |
Fixed #18023 -- Removed bundled simplejson.
And started the deprecation path for django.utils.simplejson.
Thanks Alex Ogier, Clueless, and other contributors for their
work on the patch.
Diffstat (limited to 'docs/topics')
| -rw-r--r-- | docs/topics/class-based-views.txt | 2 | ||||
| -rw-r--r-- | docs/topics/serialization.txt | 23 |
2 files changed, 8 insertions, 17 deletions
diff --git a/docs/topics/class-based-views.txt b/docs/topics/class-based-views.txt index 6df8f78250..abac22000f 100644 --- a/docs/topics/class-based-views.txt +++ b/docs/topics/class-based-views.txt @@ -501,8 +501,8 @@ different rendering behavior. For example, a simple JSON mixin might look something like this:: + import json from django import http - from django.utils import simplejson as json class JSONResponseMixin(object): def render_to_response(self, context): diff --git a/docs/topics/serialization.txt b/docs/topics/serialization.txt index d7d72ec48a..d5a5282945 100644 --- a/docs/topics/serialization.txt +++ b/docs/topics/serialization.txt @@ -143,15 +143,13 @@ Identifier Information ========== ============================================================== ``xml`` Serializes to and from a simple XML dialect. -``json`` Serializes to and from JSON_ (using a version of simplejson_ - bundled with Django). +``json`` Serializes to and from JSON_. ``yaml`` Serializes to YAML (YAML Ain't a Markup Language). This serializer is only available if PyYAML_ is installed. ========== ============================================================== .. _json: http://json.org/ -.. _simplejson: http://undefined.org/python/#simplejson .. _PyYAML: http://www.pyyaml.org/ Notes for specific serialization formats @@ -169,28 +167,21 @@ 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. However, if you're -using Python 2.6 or later (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:: +Be aware that not all Django output can be passed unmodified to :mod:`json`. +In particular, :ref:`lazy translation objects <lazy-translations>` need a +`special encoder`_ written for them. Something like this will work:: + import json from django.utils.functional import Promise from django.utils.encoding import force_unicode - class LazyEncoder(simplejson.JSONEncoder): + class LazyEncoder(json.JSONEncoder): def default(self, obj): if isinstance(obj, Promise): return force_unicode(obj) return super(LazyEncoder, self).default(obj) -.. _special encoder: http://svn.red-bean.com/bob/simplejson/tags/simplejson-1.7/docs/index.html +.. _special encoder: http://docs.python.org/library/json.html#encoders-and-decoders .. _topics-serialization-natural-keys: |
