Skip to main content

Deserialize

Derive Macro Deserialize 

Source
#[derive(Deserialize)]
{
    // Attributes available to this derive:
    #[serde_implicit]
}
Expand description

Derive macro for implicitly tagged enum deserialization.

Annotate one field per variant with #[serde_implicit(tag)] to mark it as the discriminant. When that key appears in the input, the deserializer commits to the corresponding variant and produces targeted error messages instead of serde’s generic “data did not match any variant” error.

Tag fields should be non-optional. During deserialization, keys whose value is null are ignored when searching for the implicit tag. If a tag field is Option<T> and the input contains "field": null, that variant will not be selected.