Skip to content

Commit 6059827

Browse files
committed
Parse non string keys in json
1 parent 083b11d commit 6059827

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

template/startup_scripts/0002_data.py

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,12 @@ def __call__(self, obj):
5050

5151
class E2BJSONFormatter(JSONFormatter):
5252
def __call__(self, obj):
53-
# Figure object is for some reason removed on execution of the cell,
54-
# so it can't be used in type_printers or with top-level import
55-
56-
if isinstance(obj, dict):
57-
return orjson.loads(orjson.dumps(obj, option=orjson.OPT_SERIALIZE_NUMPY)), {
58-
"expanded": True
59-
}
60-
61-
if isinstance(obj, list):
62-
return orjson.loads(orjson.dumps(obj, option=orjson.OPT_SERIALIZE_NUMPY)), {
63-
"expanded": True
64-
}
53+
if isinstance(obj, (list, dict)):
54+
return orjson.loads(
55+
orjson.dumps(
56+
obj, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_NON_STR_KEYS
57+
)
58+
), {"expanded": True}
6559

6660
return super().__call__(obj)
6761

0 commit comments

Comments
 (0)