Make the JSON parser accept trailing whitespace
This commit is contained in:
parent
4e4172ec85
commit
fb77b13174
@ -32,6 +32,7 @@ impl<Iter: Iterator<Item=u8>> Parser<Iter> {
|
||||
|
||||
#[inline]
|
||||
pub fn end(&mut self) -> Result<(), Error> {
|
||||
self.parse_whitespace();
|
||||
if self.eof() {
|
||||
Ok(())
|
||||
} 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]),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user