Skip to content

Commit b4d9afe

Browse files
committed
Try orjson encoding without cleaning first
1 parent 3c3fde6 commit b4d9afe

File tree

1 file changed

+12
-0
lines changed
  • packages/python/plotly/plotly/io

1 file changed

+12
-0
lines changed

packages/python/plotly/plotly/io/_json.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,18 @@ def _to_json_plotly(plotly_object, pretty=False, engine=None):
192192
if pretty:
193193
opts |= orjson.OPT_INDENT_2
194194

195+
# Plotly
196+
try:
197+
plotly_object = plotly_object.to_plotly_json()
198+
except AttributeError:
199+
pass
200+
201+
# Try without cleaning
202+
try:
203+
return orjson.dumps(plotly_object, option=opts).decode("utf8")
204+
except TypeError:
205+
pass
206+
195207
cleaned = clean_to_json_compatible(
196208
plotly_object, numpy_allowed=True, datetime_allowed=True, modules=modules,
197209
)

0 commit comments

Comments
 (0)