Skip to content

Disambiguating between the absence of a value and null is hard #376

@chris-morgan

Description

@chris-morgan

At present, I believe supporting the absence of a value requires Option (hard coded) or #[serde(default)].

Option’s Deserialize implementation treats null as None and anything else as Some(…).

The effect of this is that you can’t distinguish between a missing value and null without either (a) making a custom Option-like type with an additional None variant and using #[serde(default)] every time you use it; or (b) a custom deserializer.

It’d be nice to have a better way of doing this, or at the very least a canonical version of one or both of these workarounds.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions