You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Changing behavior for map key: The type of key must be string or number #255
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.
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.
Activity
gfx commentedon 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.
Mapcan have any type of keys, but easiest solution is not to use non-string objects as keys.PejmanNik commentedon Feb 5, 2025
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 commentedon Feb 6, 2025
Yes, I think callbacks may be better. But be careful, performance is important. I might reject any PRs that affect performance.
adding support for nonstandard map key in the decoder