mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-04-23 04:48:01 +00:00
Fix parsing json into optional types
Does not yet handle parsing missing values as `None` yet though. Closes #25.
This commit is contained in:
@@ -392,6 +392,24 @@ impl<Iter: Iterator<Item=u8>> de::Deserializer for Deserializer<Iter> {
|
||||
{
|
||||
self.parse_value(visitor)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_option<V>(&mut self, mut visitor: V) -> Result<V::Value, Error>
|
||||
where V: de::Visitor,
|
||||
{
|
||||
self.parse_whitespace();
|
||||
|
||||
if self.eof() {
|
||||
return Err(self.error(ErrorCode::EOFWhileParsingValue));
|
||||
}
|
||||
|
||||
if self.ch_is(b'n') {
|
||||
try!(self.parse_ident(b"ull"));
|
||||
visitor.visit_none()
|
||||
} else {
|
||||
visitor.visit_some(self)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SeqVisitor<'a, Iter: 'a> {
|
||||
|
||||
Reference in New Issue
Block a user