-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
[rust] flexbuffers doesn't keep the order of IndexMap #6120
Comments
Unfortunately, I think this is intended behavior.
https://google.github.io/flatbuffers/flatbuffers_internals.html (unless indexmap could be serialized as something besides a flexbuffers map) |
I think we want the default for |
you'd probably have to take a lot of serialization formats into account if you want to change how indexmap interacts with Serde, but for Flexbuffers, I think a flat heterogenous sequence of Separate sequences would be more efficient if all the keys or values are the same FlexbufferType (basically int, uint, str, bool), so we won't store type information - but I wouldn't expect that to be generally true. |
indexmap
is a crate which provides the typeIndexMap
, which is an order-preserving map. When encoding it with JSON, the order is restored. However, not with flexbuffers.I am not sure if this should be considered a bug in
flexbuffers
, a bug inindexmap
or a shortcoming ofserde
. The implementation ofserse::Serialize for IndexMap
usesserialize_map
which does not specify if the keys should keep the order.I am not familiar with how flexbuffer encodes maps, but could it be made to preserve order somehow?
Related issues
indexmap-rs/indexmap#156
Reproduce
with
indexmap = { version = "=1.6.0", features = ["serde-1"] }
:This fails with
The text was updated successfully, but these errors were encountered: