mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 01:18:02 +00:00
allow the deserializer to optionally handle missing fields
This allows json to deserialize missing values as a `null`.
This commit is contained in:
+7
-5
@@ -240,11 +240,6 @@ mod deserializer {
|
||||
SyntaxError
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn missing_field_error(&mut self, _field: &'static str) -> Error {
|
||||
SyntaxError
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn unexpected_name_error(&mut self, _token: de::Token) -> Error {
|
||||
SyntaxError
|
||||
@@ -254,6 +249,13 @@ mod deserializer {
|
||||
fn conversion_error(&mut self, _token: de::Token) -> Error {
|
||||
SyntaxError
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn missing_field<
|
||||
T: de::Deserializable
|
||||
>(&mut self, _field: &'static str) -> Result<T, Error> {
|
||||
Err(SyntaxError)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user