Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error in orjson engine when a dict has a non-string value as a key #3351

Merged
merged 2 commits into from
Aug 20, 2021

Conversation

jonmmease
Copy link
Contributor

Background

Python's built-in json library can handle encoding dictionaries with keys that aren't strings by coercing them to strings implicitly. The orjson library requires the keys to be strings, otherwise an error is raised.

This would very rarely come up in plotly figures. But now that we're updating Dash (for Dash 2) to use the active plotly.py json engine, it comes up on occasion.

Change

All dict keys are converted to strings during the existing cleaning pass that is used prior to orjson encoding.

Tests

Test added that encodes a dict with integer keys.

@jonmmease jonmmease mentioned this pull request Aug 19, 2021
19 tasks
@nicolaskruchten
Copy link
Contributor

💃

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants