Because prefix-underscore names are often used in Rust to suppress the "unused variable" lint, Serde automatically renames Actually, no. This happens only because you are using _links
to links
.serde(rename_all = "camelCase")
, which deletes all underscores. (Not sure why you were using that, since the field names are already camel cased...)
You can instead just tell Serde exactly what name to use for serialization:
#[serde(rename = "_links")]
pub links: HashMap<String, Link>,
(When you use serde(rename = "name")
, the renamed field is not subject to being renamed again by rename_all
.)