Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern crate serde_json; // 1.0.38
- use serde_json::Value;
- fn sort_json(s: &str) -> String {
- let obj: Value = serde_json::from_str(s).expect("Unable to deserialize JSON object");
- serde_json::to_string(&obj).expect("Unable to serialize JSON object")
- }
- fn main() {
- println!("{:?}", sort_json(r#"{"c": 3, "b": 2, "a": 1, "nested": {"z": 1, "a": 2}}"#));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement