[py3] Fixed JSON deserialization
This commit is contained in:
parent
b82eb10b26
commit
7d0f883192
|
@ -61,13 +61,12 @@ def Deserializer(stream_or_string, **options):
|
||||||
"""
|
"""
|
||||||
Deserialize a stream or string of JSON data.
|
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):
|
if isinstance(stream_or_string, bytes):
|
||||||
stream_or_string = stream_or_string.decode('utf-8')
|
stream_or_string = stream_or_string.decode('utf-8')
|
||||||
try:
|
try:
|
||||||
if isinstance(stream_or_string, six.string_types):
|
|
||||||
objects = json.loads(stream_or_string)
|
objects = json.loads(stream_or_string)
|
||||||
else:
|
|
||||||
objects = json.load(stream_or_string)
|
|
||||||
for obj in PythonDeserializer(objects, **options):
|
for obj in PythonDeserializer(objects, **options):
|
||||||
yield obj
|
yield obj
|
||||||
except GeneratorExit:
|
except GeneratorExit:
|
||||||
|
|
Loading…
Reference in New Issue