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