Created
March 22, 2016 00:25
-
-
Save cengiz-io/d0ede05abc91d0e14004 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #![feature(custom_derive, plugin)] | |
| #![plugin(serde_macros)] | |
| extern crate serde; | |
| extern crate serde_json; | |
| #[derive(Serialize, Deserialize, Debug)] | |
| struct Point { | |
| x: i32, | |
| y: i32, | |
| } | |
| fn main() { | |
| let point = Point { x: 1, y: 2 }; | |
| let serialized = serde_json::to_string(&line).unwrap(); | |
| println!("{}", serialized); | |
| let deserialized: Point = serde_json::from_str(&serialized).unwrap(); | |
| println!("{:?}", deserialized); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment