serde: Capture other unrecognized fields
#[derive(Serialize, Deserialize)]
struct S {
a: u32,
b: String,
#[serde(other)]
other: Map<String, Value>,
}
{"a":0,"b":"","c":true}
This would deserialize into other
containing “c” => true.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 13
- Comments: 31 (25 by maintainers)
Implemented in #1179, released in Serde 1.0.34.
I personally would prefer naming this something more verbose like
other_fields
. The extra typing will make the attribute more understandable in the long run, and right now, I wouldn’t know whatother
means without having it explained.