Skip to content

Commit fc0df25

Browse files
committed
[FIX] orjson: support null dict keys
json allows the dump of a dict with a null key but orjson raises an error 'TypeError: Dict key must be str' Part-of: #155 Related: odoo/upgrade#6662 Signed-off-by: Christophe Simonis (chs) <[email protected]>
1 parent 067ebbb commit fc0df25

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/util/json.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def load(fp):
1616
else:
1717

1818
def dumps(value, sort_keys=False):
19-
option = orjson.OPT_SORT_KEYS if sort_keys else None
19+
option = orjson.OPT_NON_STR_KEYS
20+
if sort_keys:
21+
option |= orjson.OPT_SORT_KEYS
2022
return orjson.dumps(value, option=option).decode()
2123

2224
def loads(value):

0 commit comments

Comments
 (0)