initial
This commit is contained in:
17
src/main.rs
Normal file
17
src/main.rs
Normal file
@@ -0,0 +1,17 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[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 = {}", serialized);
|
||||
|
||||
let deserialized: Point = serde_json::from_str(&serialized).unwrap();
|
||||
println!("deserialized = {:?}", deserialized);
|
||||
}
|
||||
Reference in New Issue
Block a user