-Documentation
This commit is contained in:
+70
-70
@@ -1,71 +1,71 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<topic id="ContractResolver" revisionNumber="1">
|
||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!--
|
||||
<summary>
|
||||
<para>Optional summary abstract</para>
|
||||
</summary>
|
||||
-->
|
||||
<introduction>
|
||||
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||
interface provides a way to customize how the
|
||||
JsonSerializer serializes and deserializes .NET objects to JSON.</para>
|
||||
<para>Implementing the IContractResolver interface and then assigning an
|
||||
instance to a JsonSerializer lets you control whether the object is
|
||||
serialized as a JSON object or JSON array, what object members should be
|
||||
serialized, how they are serialized and what they are called.</para>
|
||||
</introduction>
|
||||
<!-- Add one or more top-level section elements. These are collapsible.
|
||||
If using <autoOutline />, add an address attribute to identify it
|
||||
and specify a title so that it can be jumped to with a hyperlink. -->
|
||||
<section>
|
||||
<title>DefaultContractResolver</title>
|
||||
<content>
|
||||
<!-- Uncomment this to create a sub-section outline
|
||||
<autoOutline /> -->
|
||||
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
||||
is the default resolver used by the
|
||||
serializer. It provides many avenues of extensibility in the form of
|
||||
virtual methods that can be overriden.</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>CamelCasePropertyNamesContractResolver</title>
|
||||
<content>
|
||||
<!-- Uncomment this to create a sub-section outline
|
||||
<autoOutline /> -->
|
||||
<para><codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
||||
inherits from DefaultContractResolver and simply overrides the JSON
|
||||
property name to be written in <externalLink>
|
||||
<linkText>camelcase</linkText>
|
||||
<linkUri>http://en.wikipedia.org/wiki/CamelCase</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ContractResolver" title="ContractResolver" />
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Custom Examples</title>
|
||||
<content>
|
||||
<para>Setting a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> on a type
|
||||
using an IContractResolver.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
||||
|
||||
<para><externalLink>
|
||||
<linkText>Conditionally serializing properties</linkText>
|
||||
<linkUri>ConditionalProperties.htm</linkUri>
|
||||
<linkTarget>_self</linkTarget>
|
||||
</externalLink> using an IContractResolver.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
|
||||
</content>
|
||||
</section>
|
||||
<relatedTopics>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
||||
</relatedTopics>
|
||||
</developerConceptualDocument>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<topic id="ContractResolver" revisionNumber="1">
|
||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<!--
|
||||
<summary>
|
||||
<para>Optional summary abstract</para>
|
||||
</summary>
|
||||
-->
|
||||
<introduction>
|
||||
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||
interface provides a way to customize how the
|
||||
JsonSerializer serializes and deserializes .NET objects to JSON without placing attributes on your classes.</para>
|
||||
<para>Implementing the IContractResolver interface and then assigning an
|
||||
instance to a JsonSerializer lets you control whether the object is
|
||||
serialized as a JSON object or JSON array, what object members should be
|
||||
serialized, how they are serialized and what they are called.</para>
|
||||
</introduction>
|
||||
<!-- Add one or more top-level section elements. These are collapsible.
|
||||
If using <autoOutline />, add an address attribute to identify it
|
||||
and specify a title so that it can be jumped to with a hyperlink. -->
|
||||
<section>
|
||||
<title>DefaultContractResolver</title>
|
||||
<content>
|
||||
<!-- Uncomment this to create a sub-section outline
|
||||
<autoOutline /> -->
|
||||
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
||||
is the default resolver used by the
|
||||
serializer. It provides many avenues of extensibility in the form of
|
||||
virtual methods that can be overriden.</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>CamelCasePropertyNamesContractResolver</title>
|
||||
<content>
|
||||
<!-- Uncomment this to create a sub-section outline
|
||||
<autoOutline /> -->
|
||||
<para><codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
||||
inherits from DefaultContractResolver and simply overrides the JSON
|
||||
property name to be written in <externalLink>
|
||||
<linkText>camelcase</linkText>
|
||||
<linkUri>http://en.wikipedia.org/wiki/CamelCase</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ContractResolver" title="ContractResolver" />
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Custom Examples</title>
|
||||
<content>
|
||||
<para>Setting a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> on a type
|
||||
using an IContractResolver.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
||||
|
||||
<para><externalLink>
|
||||
<linkText>Conditionally serializing properties</linkText>
|
||||
<linkUri>ConditionalProperties.htm</linkUri>
|
||||
<linkTarget>_self</linkTarget>
|
||||
</externalLink> using an IContractResolver.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
|
||||
</content>
|
||||
</section>
|
||||
<relatedTopics>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
||||
</relatedTopics>
|
||||
</developerConceptualDocument>
|
||||
</topic>
|
||||
@@ -19,11 +19,20 @@
|
||||
<listItem><para>Single child text nodes are a value directly against an element, otherwise they are accessed via #text.</para></listItem>
|
||||
<listItem><para>The XML declaration and processing instructions are prefixed with ?.</para></listItem>
|
||||
<listItem><para>Charater data, comments, whitespace and significate whitespace nodes are accessed via
|
||||
#cdata-section, #comment, #whitespace and #significate-whitespace respectively. </para></listItem>
|
||||
#cdata-section, #comment, #whitespace and #significate-whitespace respectively.</para></listItem>
|
||||
<listItem><para>Multiple nodes with the same name at the same level are grouped together into an array.</para></listItem>
|
||||
<listItem><para>Empty elements are null.</para></listItem>
|
||||
</list>
|
||||
|
||||
<para>If the XML created from JSON doesn't match what you want then you will need to convert it manually.
|
||||
The best approach to do this is to load your JSON into a LINQ to JSON object like JObject or JArray and then use LINQ to create
|
||||
an XDocument. The opposite process, using LINQ with an XDocument to create a JObject or JArray, also works.
|
||||
Find out more about using LINQ to JSON with LINQ <externalLink>
|
||||
<linkText>here</linkText>
|
||||
<linkUri>QueryingLINQtoJSON.htm</linkUri>
|
||||
<linkTarget>_self</linkTarget>
|
||||
</externalLink>.</para>
|
||||
|
||||
<alert class="note">
|
||||
<para>The version of Json.NET being used in your application will change what XML conversion methods are available.
|
||||
SerializeXmlNode/DeserializeXmlNode are available when the framework supports XmlDocument,
|
||||
|
||||
+90
-83
@@ -1,84 +1,91 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<topic id="Performance" revisionNumber="1">
|
||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<introduction>
|
||||
<para>Out of the box Json.NET is faster than DataContractJsonSerializer and JavaScriptSerializer.
|
||||
Here are some tips to make it go even faster.</para>
|
||||
</introduction>
|
||||
<section>
|
||||
<title>Optimize Memory Usage</title>
|
||||
<content>
|
||||
<para>To keep an application consistantly fast it is important to minimize the
|
||||
amount of time the .NET framework spends performing <externalLink>
|
||||
<linkText>garbage collection</linkText>
|
||||
<linkUri>http://msdn.microsoft.com/en-us/library/ms973837.aspx</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.
|
||||
Allocating too many objects, or allocating very large objects can slow down or even
|
||||
halt an application while garbage collection is in progress.
|
||||
</para>
|
||||
<para>To minimize memory usage and the number of objects allocated Json.NET supports
|
||||
serializing and deserializing directly to a stream. Reading or writing JSON a piece at a time instead of having
|
||||
the entire JSON string loaded into memory is especially important when working with JSON
|
||||
documents greater than 85kb in size to avoid the JSON string ending up in the <externalLink>
|
||||
<linkText>large object heap</linkText>
|
||||
<linkUri>http://msdn.microsoft.com/en-us/magazine/cc534993.aspx</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="DeserializeString" title="Deserialize String" />
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="DeserializeStream" title="Deserialize Stream" />
|
||||
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>JsonConverters</title>
|
||||
<content>
|
||||
<para>Passing a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> to SerializeObject or DeserializeObject provides a simple way to completely
|
||||
change how an object is serialized. There is however a small overhead; the CanConvert method is called for every
|
||||
value to check whether serialization should be handled by that JsonConverter.</para>
|
||||
<para>There are a couple of ways to continue to use JsonConverters without any overhead. The simplest way
|
||||
is to specify the JsonConverter using the <codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>. This attribute tells the serializer
|
||||
to always use that converter when serializing and deserializing the type, without the check.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterAttribute" title="Use JsonConverter with JsonConverterAttribute" />
|
||||
|
||||
<para>If the class you want to convert isn't your own and you're unable to use an attribute a JsonConverter can still be used by
|
||||
creating your own <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
||||
|
||||
<para>The IContractResolver in the example above will set all DateTimes to use the JavaScriptDateConverter.</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Manually Serialize</title>
|
||||
<content>
|
||||
<para>The absolute fastest way to read and write JSON is to use JsonTextReader/JsonTextWriter directly to manually serialize types.
|
||||
Using a reader or writer directly skips any of the overhead from a serializer such as reflection.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="ReaderWriter" title="Manually serialize using JsonTextWriter" />
|
||||
|
||||
<para>If performance is important and you don't mind more code to get it then this is your best choice.</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Benchmarks</title>
|
||||
<content>
|
||||
|
||||
<mediaLink>
|
||||
<image class="image" xlink:href="performance" mimeType="image/png" width="643" height="345" />
|
||||
<summary>Json.NET Performance</summary>
|
||||
</mediaLink>
|
||||
|
||||
</content>
|
||||
</section>
|
||||
<relatedTopics>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference>
|
||||
</relatedTopics>
|
||||
</developerConceptualDocument>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<topic id="Performance" revisionNumber="1">
|
||||
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<introduction>
|
||||
<para>Out of the box Json.NET is faster than DataContractJsonSerializer and JavaScriptSerializer.
|
||||
Here are some tips to make it go even faster.</para>
|
||||
</introduction>
|
||||
<section>
|
||||
<title>Optimize Memory Usage</title>
|
||||
<content>
|
||||
<para>To keep an application consistantly fast it is important to minimize the
|
||||
amount of time the .NET framework spends performing <externalLink>
|
||||
<linkText>garbage collection</linkText>
|
||||
<linkUri>http://msdn.microsoft.com/en-us/library/ms973837.aspx</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.
|
||||
Allocating too many objects, or allocating very large objects can slow down or even
|
||||
halt an application while garbage collection is in progress.
|
||||
</para>
|
||||
<para>To minimize memory usage and the number of objects allocated Json.NET supports
|
||||
serializing and deserializing directly to a stream. Reading or writing JSON a piece at a time instead of having
|
||||
the entire JSON string loaded into memory is especially important when working with JSON
|
||||
documents greater than 85kb in size to avoid the JSON string ending up in the <externalLink>
|
||||
<linkText>large object heap</linkText>
|
||||
<linkUri>http://msdn.microsoft.com/en-us/magazine/cc534993.aspx</linkUri>
|
||||
<linkTarget>_blank</linkTarget>
|
||||
</externalLink>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="DeserializeString" title="Deserialize String" />
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="DeserializeStream" title="Deserialize Stream" />
|
||||
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>JsonConverters</title>
|
||||
<content>
|
||||
<para>Passing a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> to SerializeObject or DeserializeObject provides a simple way to completely
|
||||
change how an object is serialized. There is however a small overhead; the CanConvert method is called for every
|
||||
value to check whether serialization should be handled by that JsonConverter.</para>
|
||||
<para>There are a couple of ways to continue to use JsonConverters without any overhead. The simplest way
|
||||
is to specify the JsonConverter using the <codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>. This attribute tells the serializer
|
||||
to always use that converter when serializing and deserializing the type, without the check.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterAttribute" title="Use JsonConverter with JsonConverterAttribute" />
|
||||
|
||||
<para>If the class you want to convert isn't your own and you're unable to use an attribute a JsonConverter can still be used by
|
||||
creating your own <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
||||
|
||||
<para>The IContractResolver in the example above will set all DateTimes to use the JavaScriptDateConverter.</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Manually Serialize</title>
|
||||
<content>
|
||||
<para>The absolute fastest way to read and write JSON is to use JsonTextReader/JsonTextWriter directly to manually serialize types.
|
||||
Using a reader or writer directly skips any of the overhead from a serializer such as reflection.</para>
|
||||
|
||||
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="ReaderWriter" title="Manually serialize using JsonTextWriter" />
|
||||
|
||||
<para>If performance is important and you don't mind more code to get it then this is your best choice. Read more about using JsonReader/JsonWriter here:
|
||||
<externalLink>
|
||||
<linkText>Basic Reading and Writing JSON</linkText>
|
||||
<linkUri>ReadingWritingJSON.aml</linkUri>
|
||||
<linkTarget>_self</linkTarget>
|
||||
</externalLink>
|
||||
|
||||
</para>
|
||||
</content>
|
||||
</section>
|
||||
<section>
|
||||
<title>Benchmarks</title>
|
||||
<content>
|
||||
|
||||
<mediaLink>
|
||||
<image class="image" xlink:href="performance" mimeType="image/png" width="643" height="345" />
|
||||
<summary>Json.NET Performance</summary>
|
||||
</mediaLink>
|
||||
|
||||
</content>
|
||||
</section>
|
||||
<relatedTopics>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference>
|
||||
<codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference>
|
||||
</relatedTopics>
|
||||
</developerConceptualDocument>
|
||||
</topic>
|
||||
@@ -7,12 +7,7 @@
|
||||
</summary>
|
||||
-->
|
||||
<introduction>
|
||||
<!-- Uncomment this to generate an outline of the section and sub-section
|
||||
titles. Specify a numeric value as the inner text to limit it to
|
||||
a specific number of sub-topics when creating the outline. Specify
|
||||
zero (0) to limit it to top-level sections only. -->
|
||||
<!-- <autoOutline /> -->
|
||||
<para> The Json.NET serializer can serialize a wide variety of .NET objects. This guide looks at how it works, first at a high level and then in more detail.</para>
|
||||
<para>The Json.NET serializer can serialize a wide variety of .NET objects. This guide looks at how it works, first at a high level and then in more detail.</para>
|
||||
</introduction>
|
||||
<!-- Add one or more top-level section elements. These are collapsible.
|
||||
If using <autoOutline />, add an address attribute to identify it
|
||||
@@ -41,11 +36,11 @@
|
||||
</tableHeader>
|
||||
<row>
|
||||
<entry><para><legacyBold>IList, IEnumerable, IList<T>, Array</legacyBold></para></entry>
|
||||
<entry><para>Array</para></entry>
|
||||
<entry><para>Array (properties on the collection will not be serialized)</para></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><para><legacyBold>IDictionary, IDictionary<TKey, TValue></legacyBold></para></entry>
|
||||
<entry><para>Object</para></entry>
|
||||
<entry><para>Object (dictionary name/values only, properties on the dictionary will not be serialized)</para></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><para><legacyBold>Object (more detail below)</legacyBold></para></entry>
|
||||
|
||||
@@ -61,8 +61,12 @@
|
||||
|
||||
<section>
|
||||
<title>ReferenceLoopHandling</title>
|
||||
<content><para><codeEntityReference>T:Newtonsoft.Json.ReferenceLoopHandling</codeEntityReference> controls how circular referencing objects, e.g. a Person object referencing itself via a Manager property, are serialized.</para>
|
||||
|
||||
<content>
|
||||
<para><codeEntityReference>T:Newtonsoft.Json.ReferenceLoopHandling</codeEntityReference> controls how circular referencing objects,
|
||||
e.g. a Person object referencing itself via a Manager property, are serialized.</para>
|
||||
<para>The <codeEntityReference>M:System.Object.Equals(System.Object)</codeEntityReference> method is used to test whether an object is in a circular reference.
|
||||
By default <codeInline>Object.Equals(Object)</codeInline> will test whether the references are equal for reference types and private and public values
|
||||
are equal for value types. Classes and structs can override this method.</para>
|
||||
<table>
|
||||
<tableHeader>
|
||||
<row>
|
||||
@@ -83,7 +87,11 @@
|
||||
<entry><para>This option forces Json.NET to serialize objects in reference loops. This is useful if objects are nested but not indefinitely.</para></entry>
|
||||
</row>
|
||||
</table>
|
||||
<para>ReferenceLoopHandling can also be customized on individual properties with JsonPropertyAttribute.</para>
|
||||
<para>ReferenceLoopHandling can be used as an argument when calling the serializer, it can be set on an object's properties or
|
||||
a collection's items using <codeEntityReference>P:Newtonsoft.Json.JsonContainerAttribute.ItemReferenceLoopHandling</codeEntityReference>,
|
||||
customized on a property with <codeEntityReference>P:Newtonsoft.Json.JsonPropertyAttribute.ReferenceLoopHandling</codeEntityReference>
|
||||
or a property's object properties or collection items using
|
||||
<codeEntityReference>P:Newtonsoft.Json.JsonPropertyAttribute.ItemReferenceLoopHandling</codeEntityReference>.</para>
|
||||
</content>
|
||||
</section>
|
||||
|
||||
@@ -171,7 +179,16 @@
|
||||
|
||||
<section>
|
||||
<title>TypeNameHandling</title>
|
||||
<content><para><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 deserialization.</para>
|
||||
<content>
|
||||
<para>
|
||||
<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
|
||||
deserialization.
|
||||
</para>
|
||||
<para>
|
||||
The value of the $type property can be customized by creating your own
|
||||
<codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference>.
|
||||
</para>
|
||||
|
||||
<table>
|
||||
<tableHeader>
|
||||
@@ -201,8 +218,11 @@
|
||||
<entry><para>Json.NET will write and use type names for objects and collections.</para></entry>
|
||||
</row>
|
||||
</table>
|
||||
<para>TypeNameHandling can also be customized on individual properties with JsonPropertyAttribute.</para>
|
||||
|
||||
<para>TypeNameHandling can be used as an argument when calling the serializer, it can be set on an object's properties or
|
||||
a collection's items using <codeEntityReference>P:Newtonsoft.Json.JsonContainerAttribute.ItemTypeNameHandling</codeEntityReference>,
|
||||
customized on a property with <codeEntityReference>P:Newtonsoft.Json.JsonPropertyAttribute.TypeNameHandling</codeEntityReference>
|
||||
or a property's object properties or collection items using
|
||||
<codeEntityReference>P:Newtonsoft.Json.JsonPropertyAttribute.ItemTypeNameHandling</codeEntityReference>.</para>
|
||||
</content>
|
||||
</section>
|
||||
|
||||
@@ -274,9 +294,14 @@
|
||||
using its CanConvert to see if it should be used. If CanConvert returns true then the JsonConverter will be used to read or write
|
||||
the JSON for that value. Note that while a JsonConverter gives you complete control over that values JSON, many Json.NET serialization
|
||||
features are no longer available like type name and reference handling.</para>
|
||||
|
||||
<para>JsonConverters can be used as an argument when calling the serializer, it can be set on an object or property
|
||||
using <codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>, it be set on an object's properties or
|
||||
a collection's items using <codeEntityReference>P:Newtonsoft.Json.JsonContainerAttribute.ItemConverterType</codeEntityReference>,
|
||||
or a property's object properties or collection items using
|
||||
<codeEntityReference>P:Newtonsoft.Json.JsonPropertyAttribute.ItemConverterType</codeEntityReference>.</para>
|
||||
|
||||
<para>To create your own custom converter inherit from the JsonConverter class. Read more about the built-in JsonConverters below:</para>
|
||||
|
||||
|
||||
<list class="bullet">
|
||||
<listItem><para><externalLink>
|
||||
<linkText>Serializing Dates in JSON</linkText>
|
||||
|
||||
+1
-1
@@ -26,6 +26,6 @@
|
||||
<Topic id="JsonSchema" visible="True" title="Validating JSON" />
|
||||
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
|
||||
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
||||
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
|
||||
<Topic id="JsonNetVsDotNetSerializers" visible="True" isSelected="true" title="Json.NET vs .NET Serializers" />
|
||||
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
|
||||
</Topics>
|
||||
@@ -118,6 +118,7 @@
|
||||
<Compile Include="Converters\VersionConverterTests.cs" />
|
||||
<Compile Include="Documentation\ConvertingJsonAndXmlTests.cs" />
|
||||
<Compile Include="Documentation\ConditionalPropertiesTests.cs" />
|
||||
<Compile Include="Documentation\JsonNetVsWindowsDataJsonTests.cs" />
|
||||
<Compile Include="Documentation\PerformanceTests.cs" />
|
||||
<Compile Include="Documentation\JsonSchemaTests.cs" />
|
||||
<Compile Include="Documentation\ReadingAndWritingJsonTests.cs" />
|
||||
|
||||
@@ -64,8 +64,8 @@ namespace Newtonsoft.Json.Tests
|
||||
[TestFixture]
|
||||
public class PerformanceTests : TestFixtureBase
|
||||
{
|
||||
//private const int Iterations = 100;
|
||||
private const int Iterations = 5000;
|
||||
private const int Iterations = 100;
|
||||
//private const int Iterations = 5000;
|
||||
|
||||
#region Data
|
||||
|
||||
|
||||
@@ -76,5 +76,5 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.5.10.15501")]
|
||||
[assembly: AssemblyFileVersion("4.5.10.15502")]
|
||||
#endif
|
||||
|
||||
@@ -90,7 +90,7 @@ using System.Security;
|
||||
// by using the '*' as shown below:
|
||||
[assembly: AssemblyVersion("4.5.0.0")]
|
||||
#if !PocketPC
|
||||
[assembly: AssemblyFileVersion("4.5.10.15501")]
|
||||
[assembly: AssemblyFileVersion("4.5.10.15502")]
|
||||
#endif
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
|
||||
Reference in New Issue
Block a user