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

Support Symbols for Hash keys #570

Open
mperham opened this issue Mar 1, 2024 · 1 comment
Open

Support Symbols for Hash keys #570

mperham opened this issue Mar 1, 2024 · 1 comment

Comments

@mperham
Copy link
Contributor

mperham commented Mar 1, 2024

json/add/core does not support Symbols for Hash keys today. This is a major issue for downstream systems like Sidekiq which rely on JSON for serialization because we can't transparently serialize the full range of method arguments like keywords.

I'd like to propose a way to support Symbol'd keys by "smuggling" the type in the String itself:

{
  :mike => 123
}
{
  "_s:mike": 123
}

This would allow Sidekiq users to use keyword arguments in their jobs without any issues. What do you think?

See also sidekiq/sidekiq#6209

@mperham
Copy link
Contributor Author

mperham commented Mar 1, 2024

And I would be perfectly ok with this being opt-in: JSON.generate(..., type_smuggling: true)

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

No branches or pull requests

1 participant