mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-22 22:58:02 +00:00
17 lines
341 B
Rust
17 lines
341 B
Rust
#[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(&point).unwrap();
|
|
|
|
println!("{}", serialized);
|
|
|
|
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
|
|
|
|
println!("{:?}", deserialized);
|
|
}
|