We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f72f3f1 commit d1a7436Copy full SHA for d1a7436
unix-ffi/json/json/__init__.py
@@ -354,8 +354,8 @@ def loads(
354
object_pairs_hook=None,
355
**kw
356
):
357
- """Deserialize ``s`` (a ``str`` instance containing a JSON
358
- document) to a Python object.
+ """Deserialize ``s`` (a ``str``, ``bytes`` or ``bytearray`` instance
+ containing a JSON document) to a Python object.
359
360
``object_hook`` is an optional function that will be called with the
361
result of any object literal decode (a ``dict``). The return value of
@@ -413,4 +413,6 @@ def loads(
413
kw["parse_int"] = parse_int
414
if parse_constant is not None:
415
kw["parse_constant"] = parse_constant
416
+ if isinstance(s, (bytes, bytearray)):
417
+ s = s.decode('utf-8')
418
return cls(**kw).decode(s)
0 commit comments