diff --git a/serde2/src/json/de.rs b/serde2/src/json/de.rs index 85e23a4d..d0114875 100644 --- a/serde2/src/json/de.rs +++ b/serde2/src/json/de.rs @@ -32,6 +32,7 @@ impl> Parser { #[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]), + ]); + } }