From 60cce16d4317223a4e0882b7182616d702bfeb41 Mon Sep 17 00:00:00 2001 From: James Newton-King Date: Sun, 13 Dec 2015 20:40:33 +1300 Subject: [PATCH] -Documentation --- Doc/SerializationSettings.aml | 13 +++++++++++-- Doc/doc.shfbproj | 2 +- .../Serialization/MissingMemberHandlingTests.cs | 10 ++++++++++ Src/Newtonsoft.Json/JsonSerializer.cs | 5 +++++ Src/Newtonsoft.Json/JsonSerializerSettings.cs | 5 +++++ Src/Newtonsoft.Json/TypeNameHandling.cs | 6 ++++++ 6 files changed, 38 insertions(+), 3 deletions(-) diff --git a/Doc/SerializationSettings.aml b/Doc/SerializationSettings.aml index 945ae811..98a227a5 100644 --- a/Doc/SerializationSettings.aml +++ b/Doc/SerializationSettings.aml @@ -180,16 +180,25 @@ or a property's object properties or collection items using
TypeNameHandling + + + T:Newtonsoft.Json.TypeNameHandling should be used with caution when your application deserializes JSON from an external source. + + + Incoming types should be validated with a custom T:System.Runtime.Serialization.SerializationBinder when deserializing with a value other than TypeNameHandling.None. + + + T:Newtonsoft.Json.TypeNameHandling controls whether Json.NET includes .NET type names during serialization with a $type property and reads .NET type names from that property to determine what type to create during deserialization. - The value of the $type property can be customized by creating your own + The value of the $type property can be customized and validated by creating your own T:System.Runtime.Serialization.SerializationBinder. - + diff --git a/Doc/doc.shfbproj b/Doc/doc.shfbproj index 52724974..8263bced 100644 --- a/Doc/doc.shfbproj +++ b/Doc/doc.shfbproj @@ -36,7 +36,7 @@ Json.NET Documentation VS2013 MemberName - ..\Src\Newtonsoft.Json\bin\Release\Net45 + ..\Working\Src\Newtonsoft.Json\bin\Release\Net45 diff --git a/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs b/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs index 551da37c..c206a697 100644 --- a/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs +++ b/Src/Newtonsoft.Json.Tests/Serialization/MissingMemberHandlingTests.cs @@ -125,6 +125,16 @@ namespace Newtonsoft.Json.Tests.Serialization Assert.AreEqual(2, myClass.PostProperty); } + [Test] + public void CaseInsensitive() + { + string json = @"{""height"":1}"; + + DoubleClass c = JsonConvert.DeserializeObject(json, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error }); + + Assert.AreEqual(1d, c.Height); + } + [Test] public void MissingMemeber() { diff --git a/Src/Newtonsoft.Json/JsonSerializer.cs b/Src/Newtonsoft.Json/JsonSerializer.cs index b487ddc8..b9768403 100644 --- a/Src/Newtonsoft.Json/JsonSerializer.cs +++ b/Src/Newtonsoft.Json/JsonSerializer.cs @@ -138,6 +138,11 @@ namespace Newtonsoft.Json /// /// Gets or sets how type name writing and reading is handled by the serializer. /// + /// + /// should be used with caution when your application deserializes JSON from an external source. + /// Incoming types should be validated with a custom + /// when deserializing with a value other than TypeNameHandling.None. + /// public virtual TypeNameHandling TypeNameHandling { get { return _typeNameHandling; } diff --git a/Src/Newtonsoft.Json/JsonSerializerSettings.cs b/Src/Newtonsoft.Json/JsonSerializerSettings.cs index aa996c37..d3b9b49c 100644 --- a/Src/Newtonsoft.Json/JsonSerializerSettings.cs +++ b/Src/Newtonsoft.Json/JsonSerializerSettings.cs @@ -156,6 +156,11 @@ namespace Newtonsoft.Json /// /// Gets or sets how type name writing and reading is handled by the serializer. /// + /// + /// should be used with caution when your application deserializes JSON from an external source. + /// Incoming types should be validated with a custom + /// when deserializing with a value other than TypeNameHandling.None. + /// /// The type name handling. public TypeNameHandling TypeNameHandling { diff --git a/Src/Newtonsoft.Json/TypeNameHandling.cs b/Src/Newtonsoft.Json/TypeNameHandling.cs index deb0c88e..9a5a8cfe 100644 --- a/Src/Newtonsoft.Json/TypeNameHandling.cs +++ b/Src/Newtonsoft.Json/TypeNameHandling.cs @@ -24,12 +24,18 @@ #endregion using System; +using System.Runtime.Serialization; namespace Newtonsoft.Json { /// /// Specifies type name handling options for the . /// + /// + /// should be used with caution when your application deserializes JSON from an external source. + /// Incoming types should be validated with a custom + /// when deserializing with a value other than TypeNameHandling.None. + /// [Flags] public enum TypeNameHandling {