initial commit issue #931 fix

This commit is contained in:
Антон
2018-11-24 21:25:20 +13:00
committed by James Newton-King
parent c6e4ca7a94
commit a1f1b0aa86
6 changed files with 121 additions and 2 deletions
@@ -1743,5 +1743,32 @@ third line", jsonTextReader.Value);
{
}
}
[Test]
public void ThrowOnDuplicateKeysDeserializing()
{
string json = @"
{
""a"": 1,
""b"": [
{
""c"": {
""d"": 1,
""d"": ""2""
}
}
]
}
";
JsonLoadSettings settings = new JsonLoadSettings {DuplicatePropertyNamesHandling = DuplicatePropertyNamesHandling.Throw};
ExceptionAssert.Throws<JsonException>(() => JObject.Parse(json, settings));
ExceptionAssert.Throws<JsonException>(() =>
{
JsonTextReader reader = new JsonTextReader(new StringReader(json));
JToken.ReadFrom(reader, settings);
});
}
}
}