Hi, having read the serde doc, i am still not able to get it work.
here is my code:
#[derive(Debug, PartialEq, Serialize, Deserialize)]
struct Record {
score_value: u32,
player_name: String, // does not implement `Copy`
timestamp_fake: u32,
}
let yesterdayscore = Record { score_value: 1500, player_name: "yesterdayscore".to_string(), timestamp_fake: 7000 };
let myscore = Record { score_value: 800, player_name: "myscore".to_string(), timestamp_fake: 8000 };
let friendscore = Record { score_value: 800, player_name: "friendscore".to_string(), timestamp_fake: 9000 };
let mut allscores :Vec<&Record> = Vec::new();
allscores.push(&yesterdayscore);
allscores.push(&myscore);
allscores.push(&friendscore);
let serialized = serde_json::to_string(&allscores).unwrap();
println!("serialized = {}", serialized);
let deserialized: std::vec::Vec<&Record> = serde_json::from_str(&serialized).unwrap();
my goal is to save allscores in a txt file with json , and recover it
in a OOP style after derserialization.