serde-yaml
serde-yaml copied to clipboard
Allow Configuration on Option::None handling
Currently if you have an optional field in Rust:
struct Something {
maybe_not_there: Option<String>
}
Something {
maybe_not_there: None
}
And you serialize it using this crate, you get this:
something
maybe_not_there: null
However, valid yaml accepts also a tilde, no value at all, or simply omitting the key altogether.
Valid:
something
maybe_not_there: ~
something
maybe_not_there:
something
It would be nice if it were possible to configure the desired output.
For the last option, ref. https://docs.rs/serde_with/3.0.0/serde_with/attr.skip_serializing_none.html