daily pastebin goal
56%
SHARE
TWEET

Untitled

a guest Apr 21st, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #[macro_use]
  2. extern crate serde_derive;
  3.  
  4. extern crate serde;
  5. extern crate serde_json;
  6.  
  7. #[derive(Deserialize, Debug)]
  8. struct S {
  9.     dog: String,
  10.     cat: String
  11. }
  12.  
  13. fn main() {
  14.     let poodle_poop_json = String::from(r#"{"dog":"bob"}"#);
  15.     match serde_json::from_str::<S>(&poodle_poop_json) {
  16.         Ok(s) => println!("ok: {:#?}", s),
  17.         Err(err) => println!("err: {}", err),
  18.     }
  19. }
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