Loading tutorials
Result with the ? operator. You should also know what JSON looks like. Lifetimes matter only in a later chapter.2 min readSerialize and Deserialize traits and the serde data model from the earlier chapters. It also assumes you can add a Cargo dependency and read a Rust compiler error.1 min readserde_json, the crate that turns Rust values into JSON text and back. It assumes you know Rust structs, traits, Result and ?, and have a Cargo project. It also assumes you know what JSON looks like, and that you have seen `#[derive(Serialize, Deserializ2 min readSerialize and Deserialize and round-trip a struct through serde_json. Field attributes are #[serde(...)] annotations placed on individual struct fields. They change how one field is named, filled in, skipped, or merged, and the rest of the struct keeps the2 min readSerialize and Deserialize and round-trip a struct through serde_json. It also assumes you know the field attributes rename and default.2 min readSerialize and Deserialize, use serde_json, and read container attributes such as rename_all. Here you will choose how serde writes an enum as JSON.1 min readSerialize and Deserialize and call serde_json::from_str. It also assumes you are comfortable with Result and match.2 min readSerialize and Deserialize, and that you have used serde_json to round-trip a struct. Here you will reuse one type with a second format.2 min readserde_json::Value handles these cases. It is an enum that can hold any JSON document.2 min readSerialize and Deserialize, and that you are comfortable with generics and lifetimes in function signatures. It also assumes you have seen field attributes such as rename and default.2 min read#[derive(Serialize)] with serde_json. You should also know how the serde data model separates your types from formats. Add serde = { version = "1", features = ["derive"] } and serde_json = "1" to Cargo.toml.2 min readDeserialize derive, and serde_json::from_str. Here you will see how a deserialized value can borrow from its input instead of copying it.2 min readSerialize and Deserialize traits. You should also be comfortable with Rust traits, generics, and lifetimes.2 min read