-Documentation

This commit is contained in:
James Newton-King
2015-12-13 20:40:33 +13:00
parent 4c256e7afd
commit 60cce16d43
6 changed files with 38 additions and 3 deletions
+10 -1
View File
@@ -180,13 +180,22 @@ or a property's object properties or collection items using
<section> <section>
<title>TypeNameHandling</title> <title>TypeNameHandling</title>
<content> <content>
<alert class="caution">
<para>
<codeEntityReference>T:Newtonsoft.Json.TypeNameHandling</codeEntityReference> should be used with caution when your application deserializes JSON from an external source.
</para>
<para>
Incoming types should be validated with a custom <codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference> when deserializing with a value other than <c>TypeNameHandling.None</c>.
</para>
</alert>
<para> <para>
<codeEntityReference>T:Newtonsoft.Json.TypeNameHandling</codeEntityReference> controls whether Json.NET includes .NET type names <codeEntityReference>T:Newtonsoft.Json.TypeNameHandling</codeEntityReference> 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 during serialization with a $type property and reads .NET type names from that property to determine what type to create during
deserialization. deserialization.
</para> </para>
<para> <para>
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
<codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference>. <codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference>.
</para> </para>
+1 -1
View File
@@ -36,7 +36,7 @@
<HelpTitle>Json.NET Documentation</HelpTitle> <HelpTitle>Json.NET Documentation</HelpTitle>
<PresentationStyle>VS2013</PresentationStyle> <PresentationStyle>VS2013</PresentationStyle>
<NamingMethod>MemberName</NamingMethod> <NamingMethod>MemberName</NamingMethod>
<DocumentationSourcePath>..\Src\Newtonsoft.Json\bin\Release\Net45</DocumentationSourcePath> <DocumentationSourcePath>..\Working\Src\Newtonsoft.Json\bin\Release\Net45</DocumentationSourcePath>
<DocumentationSources> <DocumentationSources>
<DocumentationSource sourceFile="$(DocumentationSourcePath)\Newtonsoft.Json.dll" /> <DocumentationSource sourceFile="$(DocumentationSourcePath)\Newtonsoft.Json.dll" />
<DocumentationSource sourceFile="$(DocumentationSourcePath)\Newtonsoft.Json.xml" /> <DocumentationSource sourceFile="$(DocumentationSourcePath)\Newtonsoft.Json.xml" />
@@ -125,6 +125,16 @@ namespace Newtonsoft.Json.Tests.Serialization
Assert.AreEqual(2, myClass.PostProperty); Assert.AreEqual(2, myClass.PostProperty);
} }
[Test]
public void CaseInsensitive()
{
string json = @"{""height"":1}";
DoubleClass c = JsonConvert.DeserializeObject<DoubleClass>(json, new JsonSerializerSettings { MissingMemberHandling = MissingMemberHandling.Error });
Assert.AreEqual(1d, c.Height);
}
[Test] [Test]
public void MissingMemeber() public void MissingMemeber()
{ {
+5
View File
@@ -138,6 +138,11 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Gets or sets how type name writing and reading is handled by the serializer. /// Gets or sets how type name writing and reading is handled by the serializer.
/// </summary> /// </summary>
/// <remarks>
/// <see cref="TypeNameHandling"/> should be used with caution when your application deserializes JSON from an external source.
/// Incoming types should be validated with a custom <see cref="T:System.Runtime.Serialization.SerializationBinder"/>
/// when deserializing with a value other than <c>TypeNameHandling.None</c>.
/// </remarks>
public virtual TypeNameHandling TypeNameHandling public virtual TypeNameHandling TypeNameHandling
{ {
get { return _typeNameHandling; } get { return _typeNameHandling; }
@@ -156,6 +156,11 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Gets or sets how type name writing and reading is handled by the serializer. /// Gets or sets how type name writing and reading is handled by the serializer.
/// </summary> /// </summary>
/// <remarks>
/// <see cref="TypeNameHandling"/> should be used with caution when your application deserializes JSON from an external source.
/// Incoming types should be validated with a custom <see cref="T:System.Runtime.Serialization.SerializationBinder"/>
/// when deserializing with a value other than <c>TypeNameHandling.None</c>.
/// </remarks>
/// <value>The type name handling.</value> /// <value>The type name handling.</value>
public TypeNameHandling TypeNameHandling public TypeNameHandling TypeNameHandling
{ {
+6
View File
@@ -24,12 +24,18 @@
#endregion #endregion
using System; using System;
using System.Runtime.Serialization;
namespace Newtonsoft.Json namespace Newtonsoft.Json
{ {
/// <summary> /// <summary>
/// Specifies type name handling options for the <see cref="JsonSerializer"/>. /// Specifies type name handling options for the <see cref="JsonSerializer"/>.
/// </summary> /// </summary>
/// <remarks>
/// <see cref="TypeNameHandling"/> should be used with caution when your application deserializes JSON from an external source.
/// Incoming types should be validated with a custom <see cref="T:System.Runtime.Serialization.SerializationBinder"/>
/// when deserializing with a value other than <c>TypeNameHandling.None</c>.
/// </remarks>
[Flags] [Flags]
public enum TypeNameHandling public enum TypeNameHandling
{ {