Throw for CheckAdditionalContent when extra content is preceded by comments. (#1183)

Fixes #1182
This commit is contained in:
Jon Hanna
2017-01-16 14:48:52 +13:00
committed by James Newton-King
parent 7e4b3448c7
commit 9727996b1a
2 changed files with 52 additions and 2 deletions
@@ -169,9 +169,12 @@ namespace Newtonsoft.Json.Serialization
if (checkAdditionalContent)
{
if (reader.Read() && reader.TokenType != JsonToken.Comment)
while (reader.Read())
{
throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object.");
if (reader.TokenType != JsonToken.Comment)
{
throw new JsonSerializationException("Additional text found in JSON string after finishing deserializing object.");
}
}
}