Often people use optional or nullable types as a convenient approximation to an Either type.
{}
and { "foo": null }
and { "foo": 42 }
So I'll represent that (in e.g. Rust) as: struct Whatever {
foo: Option<Option<u32>>,
}
None means not present, Some(None) means present but null, and Some(Some(42)) means present with a value.I'll often use this in PATCH endpoints, where not-present means to leave the current value alone, null means to unset it, and a value means to set to that value.