serde-yaml icon indicating copy to clipboard operation
serde-yaml copied to clipboard

Serializing `Null` as `None`?

Open t-botz opened this issue 6 years ago • 1 comments

I have a field my_field: Option<Enum> and my yaml is like my_field: NULL.

Parsing it raise an error : "unknown variant NULL, expected one of [...]

Looking at the code I see that Null is serialized at unit which makes me wonder :

  • Why would anyone Serialize/Deserialize the unit type?
  • Shouldn't Null in yaml be None in Rust and vice versa?

(Working on a PR)

t-botz avatar Dec 13 '18 02:12 t-botz

Actually serde_yaml only support the ~ and null for Null values, hence why NULL is not recognized. It should be either:

t-botz avatar Dec 13 '18 02:12 t-botz