Skip to content

Commit 4645bd0

Browse files
committed
Fail softly when can't parse json
1 parent 6059827 commit 4645bd0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

template/startup_scripts/0002_data.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,14 @@ def __call__(self, obj):
5151
class E2BJSONFormatter(JSONFormatter):
5252
def __call__(self, obj):
5353
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}
54+
try:
55+
return orjson.loads(
56+
orjson.dumps(
57+
obj, option=orjson.OPT_SERIALIZE_NUMPY | orjson.OPT_NON_STR_KEYS
58+
)
59+
), {"expanded": True}
60+
except TypeError:
61+
pass
5962

6063
return super().__call__(obj)
6164

0 commit comments

Comments
 (0)