summaryrefslogtreecommitdiff
path: root/django/core/serializers/json.py
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-04-29 19:58:00 +0200
commitcec6bd5a59547dc97fe98975c570fc27a1e970be (patch)
treed084ff2008e4bba125c4b28297d6469992f2ec95 /django/core/serializers/json.py
parentee0a7c741e98214bac7eeb60b848cf099ff28836 (diff)
downloaddjango-cec6bd5a59547dc97fe98975c570fc27a1e970be.tar.gz
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 'django/core/serializers/json.py')
-rw-r--r--django/core/serializers/json.py13
1 files changed, 8 insertions, 5 deletions
diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
index 91af84e9ca..ab0cd0e590 100644
--- a/django/core/serializers/json.py
+++ b/django/core/serializers/json.py
@@ -2,14 +2,17 @@
Serialize data to/from JSON
"""
+# Avoid shadowing the standard library json module
+from __future__ import absolute_import
+
import datetime
import decimal
+import json
from StringIO import StringIO
from django.core.serializers.base import DeserializationError
from django.core.serializers.python import Serializer as PythonSerializer
from django.core.serializers.python import Deserializer as PythonDeserializer
-from django.utils import simplejson
from django.utils.timezone import is_aware
class Serializer(PythonSerializer):
@@ -19,10 +22,10 @@ class Serializer(PythonSerializer):
internal_use_only = False
def end_serialization(self):
- if simplejson.__version__.split('.') >= ['2', '1', '3']:
+ if json.__version__.split('.') >= ['2', '1', '3']:
# Use JS strings to represent Python Decimal instances (ticket #16850)
self.options.update({'use_decimal': False})
- simplejson.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
+ json.dump(self.objects, self.stream, cls=DjangoJSONEncoder, **self.options)
def getvalue(self):
if callable(getattr(self.stream, 'getvalue', None)):
@@ -38,7 +41,7 @@ def Deserializer(stream_or_string, **options):
else:
stream = stream_or_string
try:
- for obj in PythonDeserializer(simplejson.load(stream), **options):
+ for obj in PythonDeserializer(json.load(stream), **options):
yield obj
except GeneratorExit:
raise
@@ -47,7 +50,7 @@ def Deserializer(stream_or_string, **options):
raise DeserializationError(e)
-class DjangoJSONEncoder(simplejson.JSONEncoder):
+class DjangoJSONEncoder(json.JSONEncoder):
"""
JSONEncoder subclass that knows how to encode date/time and decimal types.
"""