Skip to content

Commit 93815c1

Browse files
committed
Try orjson encoding without cleaning first
1 parent 6cea61d commit 93815c1

File tree

1 file changed

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

1 file changed

+12
-0
lines changed

Diff for: packages/python/plotly/plotly/io/_json.py

+12
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ def to_json_plotly(plotly_object, pretty=False, engine=None):
155155
if pretty:
156156
opts |= orjson.OPT_INDENT_2
157157

158+
# Plotly
159+
try:
160+
plotly_object = plotly_object.to_plotly_json()
161+
except AttributeError:
162+
pass
163+
164+
# Try without cleaning
165+
try:
166+
return orjson.dumps(plotly_object, option=opts).decode("utf8")
167+
except TypeError:
168+
pass
169+
158170
cleaned = clean_to_json_compatible(
159171
plotly_object, numpy_allowed=True, datetime_allowed=True, modules=modules,
160172
)

0 commit comments

Comments
 (0)