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

Default to str() for Unknown objects as keys when using OPT_NON_STR_KEYS #454

Closed
wants to merge 1 commit into from

Conversation

timkpaine
Copy link

This is a rebase of #438, which was closed as stale.

When using passing a dict with OPT_NON_STR_KEYS, if the object type is Unknown, add a fallback to use the python default str() function

https://github.com/ijl/orjson/issues/424#issuecomment-1710860721

This is a feature to allow unknown types (e.g. a custom implementation of an enum in my case, but could be anything) to be keys by just naively relying on the string representation. This is not elegant, and I agree with @ijl that "This is a sort of feature request if you squint", but the current behavior is to error so I think this is a marginal improvement on that. Happy to make any changes.

@timkpaine timkpaine changed the title Default to str() for Unknown objects when using OPT_NON_STR_KEYS Default to str() for Unknown objects as keys when using OPT_NON_STR_KEYS Jan 26, 2024
@github-actions github-actions bot added the Stale label Feb 3, 2024
@github-actions github-actions bot closed this Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants