SHARE
TWEET

Untitled

a guest Apr 18th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extern crate serde_json; // 1.0.38
  2. use serde_json::Value;
  3.  
  4. fn sort_json(s: &str) -> String {
  5.     let obj: Value = serde_json::from_str(s).expect("Unable to deserialize JSON object");
  6.     serde_json::to_string(&obj).expect("Unable to serialize JSON object")
  7. }
  8.  
  9. fn main() {
  10.     println!("{:?}", sort_json(r#"{"c": 3, "b": 2, "a": 1, "nested": {"z": 1, "a": 2}}"#));
  11. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top