Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed #2515 -- Allow passing of options to JSON serializer. Thanks, n…

…esh.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@3795 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit d8b84cac9170d26b8a7033c2c7ff7a6620ac81b6 1 parent 96bc9ec
@malcolmt malcolmt authored
View
1  AUTHORS
@@ -112,6 +112,7 @@ answer newbie questions, and generally made Django that much better:
Eric Moritz <http://eric.themoritzfamily.com/>
Robin Munn <http://www.geekforgod.com/>
Nebojša Dorđević
+ nesh
Sam Newman <http://www.magpiebrain.com/>
Neal Norwitz <nnorwitz@google.com>
oggie rob <oz.robharvey@gmail.com>
View
2  django/core/serializers/json.py
@@ -16,7 +16,7 @@ class Serializer(PythonSerializer):
Convert a queryset to JSON.
"""
def end_serialization(self):
- simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder)
+ simplejson.dump(self.objects, self.stream, cls=DateTimeAwareJSONEncoder, **self.options)
def getvalue(self):
return self.stream.getvalue()
View
15 docs/serialization.txt
@@ -96,6 +96,21 @@ Django "ships" with a few included serializers:
.. _json: http://json.org/
.. _simplejson: http://undefined.org/python/#simplejson
+Notes For Specific Serialization Formats
+----------------------------------------
+
+json
+~~~~
+
+If you are using UTF-8 (or any other non-ASCII encoding) data with the JSON
+serializer, you must pass ``ensure_ascii=False`` as a parameter to the
+``serialize()`` call. Otherwise the output will not be encoded correctly.
+
+For example::
+
+ json_serializer = serializers.get_serializer("json")
+ json_serializer.serialize(queryset, ensure_ascii=False, stream=response)
+
Writing custom serializers
``````````````````````````
Please sign in to comment.
Something went wrong with that request. Please try again.