use serde::Serialize; use serde_json; #[derive(Serialize)] struct Person { name: String, age: u8, email: String, } fn main() { let person = Person { name: "Ali".to_string(), age: 30, email: "ali@example.com".to_string(), }; let json_data = serde_json::to_string(&person).unwrap(); println!("JSON: {}", json_data); }