-
Notifications
You must be signed in to change notification settings - Fork 24
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
Getting out-of-order outputs when using map builder #89
Comments
Map internally uses a HashMap. If you come up with a PR that changes the current HashMap implementation to a TreeMap one, I will merge it. |
I found that it was not the https://github.com/c-rack/cbor-java/blob/master/src/main/java/co/nstant/in/cbor/model/Map.java but the sortedMap of TreeMap |
The TreeMap is used because the CBOR specification has a section about a canonical format: One could consider to introduce a non-canoncial mode, which does not use a TreeMap. Any PRs in that direction are welcome. |
I'm also interested in map insertion order. How would you prefer to configure such a mode? |
@cavenaghi9 @beclever @illumi I have pushed an update that keeps the order of map entries if the non-canonical mode is active (see README). Publishing to maven central follows. |
@c-rack when the version 0.9 of the library will be available on maven central repository? |
I try to put key and values with MapBuilder, for instance
mapBuilder.put(-2, "v1");
mapBuilder.put(0, "v2");
However, key 0 will on first item, when encoding map. Is it possible to keep the same order what I inserted?
The text was updated successfully, but these errors were encountered: