1 use serde::{Serialize, Deserialize};
3 #[derive(Serialize, Deserialize, Debug)]
4 struct Point { x: i32, y: i32, }
7 let point = Point { x: 1, y: 2 };
9 // Convert the Point to a JSON string.
10 let j = serde_json::to_string(&point).unwrap();
12 // Parse the JSON string as a Point.
13 let p2: Point = serde_json::from_str(&j).unwrap();