mirror of
https://github.com/pezkuwichain/serde.git
synced 2026-06-12 20:11:02 +00:00
Make the JSON parser accept trailing whitespace
This commit is contained in:
@@ -32,6 +32,7 @@ impl<Iter: Iterator<Item=u8>> Parser<Iter> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn end(&mut self) -> Result<(), Error> {
|
pub fn end(&mut self) -> Result<(), Error> {
|
||||||
|
self.parse_whitespace();
|
||||||
if self.eof() {
|
if self.eof() {
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
@@ -735,4 +736,14 @@ mod tests {
|
|||||||
),
|
),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse_trailing_whitespace() {
|
||||||
|
test_parse_ok(vec![
|
||||||
|
("[1, 2] ", vec![1, 2]),
|
||||||
|
("[1, 2]\n", vec![1, 2]),
|
||||||
|
("[1, 2]\t", vec![1, 2]),
|
||||||
|
("[1, 2]\t \n", vec![1, 2]),
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user