Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [5.2.2] - ???

### Fixed
- Fixed error when using the orjson engine with non-string keys

## [5.2.1] - 2021-08-13

### Updated
Expand Down
2 changes: 1 addition & 1 deletion packages/python/plotly/plotly/io/_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ def clean_to_json_compatible(obj, **kwargs):
return obj

if isinstance(obj, dict):
return {k: clean_to_json_compatible(v, **kwargs) for k, v in obj.items()}
return {str(k): clean_to_json_compatible(v, **kwargs) for k, v in obj.items()}
elif isinstance(obj, (list, tuple)):
if obj:
# Must process list recursively even though it may be slow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,3 +209,9 @@ def test_object_array(engine, pretty):
fig = px.scatter(px.data.tips(), x="total_bill", y="tip", custom_data=["sex"])
result = fig.to_plotly_json()
check_roundtrip(result, engine=engine, pretty=pretty)


def test_nonstring_key(engine, pretty):
value = build_test_dict({0: 1})
result = pio.to_json_plotly(value, engine=engine)
check_roundtrip(result, engine=engine, pretty=pretty)