Closed reitermarkus closed 5 years ago
You mean undefined
as in absent? I think you still have to add #[serde(default)]
to handle absent fields.
You mean
undefined
as in absent? I think you still have to add#[serde(default)]
to handle absent fields.
No no, I meant this:
{ "value": undefined }
Is this valid json? If it is, should we also treat undefined
in the way we do null
and {}
?
According to jsonlint validator it is not a valid json, so I guess, the answer is no
, we don't have to handle this as it is impossible to have it and, probably, it will not even be parsed by serde
itself.
Is this valid json?
No, JSON only supports null
.
@reitermarkus Thank you!
You're welcome!
In addition to
deserialize_default_from_null
, this also treats empty objects ({}
) asnull
.Also, I fixed the
deserialize_default_from_null
. It would actually treat anErr
asnull
because I accidentally simplified the code too much and moved the.unwrap_or
from anOption
to aResult
.