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

Changing behavior for map key: The type of key must be string or number #255

Closed
PejmanNik opened this issue Feb 4, 2025 · 3 comments
Closed
Labels
wontfix It won't be fixed

Comments

@PejmanNik
Copy link

The repository has a limitation where it throws an error: "The type of key must be string or number"

I’d like to understand whether it’s acceptable to address this by converting the key to JSON before processing or by adding a callback function for the consumer to handle this case.

Using an object as a key is supported in other languages, and I need to decode data encoded with a MessagePack library from another language.

@gfx
Copy link
Member

gfx commented Feb 5, 2025

I know MessagePack spec allows any types to be used as keys, but it doesn't make sense to JavaScript's object. Map can have any type of keys, but easiest solution is not to use non-string objects as keys.

@gfx gfx closed this as completed Feb 5, 2025
@gfx gfx added the wontfix It won't be fixed label Feb 5, 2025
@PejmanNik
Copy link
Author

ok, so it won't fix but are you open to a PR for adding a callback to handle this case with the option object? or extending the key decoder for this?

@gfx
Copy link
Member

gfx commented Feb 6, 2025

are you open to a PR for adding a callback to handle this case with the option object? or extending the key decoder for this?

Yes, I think callbacks may be better. But be careful, performance is important. I might reject any PRs that affect performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix It won't be fixed
Projects
None yet
Development

No branches or pull requests

2 participants