Skip to content

Commit 444331c

Browse files
committed
modujson: .loads(): Handle more whitespace characters.
1 parent 1f04336 commit 444331c

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

extmod/modujson.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ STATIC mp_obj_t mod_ujson_loads(mp_obj_t obj) {
8181
case ',':
8282
case ':':
8383
case ' ':
84+
case '\t':
85+
case '\n':
86+
case '\r':
8487
s += 1;
8588
goto cont;
8689
case 'n':

tests/extmod/ujson_loads.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ def my_print(o):
3030
my_print(json.loads('{"a":true}'))
3131
my_print(json.loads('{"a":null, "b":false, "c":true}'))
3232
my_print(json.loads('{"a":[], "b":[1], "c":{"3":4}}'))
33+
34+
# whitespace handling
35+
my_print(json.loads('{\n\t"a":[]\r\n, "b":[1], "c":{"3":4} \n\r\t\r\r\r\n}'))

0 commit comments

Comments
 (0)