-
Notifications
You must be signed in to change notification settings - Fork 13.4k
json::to_pretty_writer output should be consistent #8557
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
Comments
Are you using rust master? Internally json now uses a TreeMap instead of a HashMap so I figured they'd be deterministic unless they're getting purposefully scrambled... |
Thanks! (No I was working on 0.7) |
Regardless, thanks for the report anyway! If you're trying out rust, I would recommend using the master branch anyway. It's got boatloads of fixes from 0.7 and it's almost always stable. |
@ozten: I caution you on relying too heavily on this feature though. The json spec explicitly states that the key/value pairs in an object are unsorted. Right now Rust's |
add `or_then_unwrap` Closes rust-lang#8557 changelog: New lint [`or_then_unwrap`]
Currently when you build up a Json object and write it to a file using
json::to_pretty_writer
, the order of the keys in objects is random.There are two possible improvements that come to mind:
Write objects based on the natural sort order of the keys
Write objects based on the order in which keys were added to the object
Most mature JSON libraries I've used do #2, but even #1 would be an acceptable first step to getting deterministic serialized output.
The text was updated successfully, but these errors were encountered: