Skip to content

Commit e53ae58

Browse files
committed
unix-ffi/json: Accept both str and bytes as arg for json.loads().
Fixes #985. Same as micropython's internal json lib does. Signed-off-by: Dominik Heidler <[email protected]>
1 parent 65a1411 commit e53ae58

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

unix-ffi/json/json/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -413,4 +413,6 @@ def loads(
413413
kw["parse_int"] = parse_int
414414
if parse_constant is not None:
415415
kw["parse_constant"] = parse_constant
416+
if isinstance(s, bytes):
417+
s = s.decode('utf-8')
416418
return cls(**kw).decode(s)

0 commit comments

Comments
 (0)