JSON: JSON, encoding/json, serde_json, nlohmann/json
#The standard library has no JSON support. The usual choice is two crates: serde, a general serialization framework whose derive macros (#[derive(Serialize, Deserialize)]) generate the conversion code, and serde_json for the JSON format (from_str, to_string, to_string_pretty and the json! macro). Unknown fields are ignored unless the struct has #[serde(deny_unknown_fields)]. Decoding checks types and required fields, so a parsed struct has the shape you declared.
Complete program
Complete program.
Before you use this
Not in the standard library: cargo add serde --features derive && cargo add serde_json
Most used: #[derive(Serialize, Deserialize)], serde_json::from_str, serde_json::to_string, to_string_pretty, json!, serde_json::Value for untyped data, #[serde(rename = "...")].