Commit 9bffd354 by Tom Christie Committed by GitHub

Handle bytestrings in JSON. Closes #4185. (#4191)

parent bb22ab8e
...@@ -51,6 +51,9 @@ class JSONEncoder(json.JSONEncoder): ...@@ -51,6 +51,9 @@ class JSONEncoder(json.JSONEncoder):
return six.text_type(obj) return six.text_type(obj)
elif isinstance(obj, QuerySet): elif isinstance(obj, QuerySet):
return tuple(obj) return tuple(obj)
elif isinstance(obj, six.binary_type):
# Best-effort for binary blobs. See #4187.
return obj.decode('utf-8')
elif hasattr(obj, 'tolist'): elif hasattr(obj, 'tolist'):
# Numpy arrays and array scalars. # Numpy arrays and array scalars.
return obj.tolist() return obj.tolist()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment