bevy_pkv icon indicating copy to clipboard operation
bevy_pkv copied to clipboard

Can't serialize maps with non-String keys on wasm

Open dgulotta opened this issue 11 months ago • 3 comments

Attempting to serialize a HashMap with non-string keys results an error in wasm (but works on native). This appears to be an intentional limitation of serde_json. It would be nice if bevy_pkv used a storage method that did not have this limitation. Since the native version uses rmp-serde, maybe just use that + base64 for wasm?

dgulotta avatar Dec 09 '24 00:12 dgulotta

Yes, that sounds like an unnecessary limitation. It would break data for any users upgrading, but I think I'm ok with that.

Must remember to put it in the release notes

johanhelsing avatar Dec 17 '24 10:12 johanhelsing

There is also a request to store using serde_json on native for (human readableness #55 ), perhaps it would make sense to have it as a feature flag, affecting both platforms.

johanhelsing avatar Dec 17 '24 10:12 johanhelsing

It would be nice to have a lower-level interface that deals with u8 slices and strs directly, in case users want to choose their serialization method. The higher-level interface that uses rmp-serde or serde-json could exist on top of that.

dgulotta avatar Dec 17 '24 16:12 dgulotta