diff options
| author | Claude Paroz <claude@2xlibre.net> | 2012-08-11 20:58:45 +0200 |
|---|---|---|
| committer | Claude Paroz <claude@2xlibre.net> | 2012-08-11 23:23:31 +0200 |
| commit | 7d0f8831922535502569a5dda989dde339b4e491 (patch) | |
| tree | 50c0d423b2f2745e92989d52209c13f75d4c2312 | |
| parent | b82eb10b2605477b3e583c9378257a9e6c8fd2ed (diff) | |
[py3] Fixed JSON deserialization
| -rw-r--r-- | django/core/serializers/json.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py index 3bac24d33a..4ba0d7fd79 100644 --- a/django/core/serializers/json.py +++ b/django/core/serializers/json.py @@ -61,13 +61,12 @@ def Deserializer(stream_or_string, **options): """ Deserialize a stream or string of JSON data. """ + if not isinstance(stream_or_string, (bytes, six.string_types)): + stream_or_string = stream_or_string.read() if isinstance(stream_or_string, bytes): stream_or_string = stream_or_string.decode('utf-8') try: - if isinstance(stream_or_string, six.string_types): - objects = json.loads(stream_or_string) - else: - objects = json.load(stream_or_string) + objects = json.loads(stream_or_string) for obj in PythonDeserializer(objects, **options): yield obj except GeneratorExit: |
