Skip to content

Instantly share code, notes, and snippets.

@cengiz-io
Created March 22, 2016 00:25
Show Gist options
  • Select an option

  • Save cengiz-io/d0ede05abc91d0e14004 to your computer and use it in GitHub Desktop.

Select an option

Save cengiz-io/d0ede05abc91d0e14004 to your computer and use it in GitHub Desktop.
#![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