-Examples!
This commit is contained in:
+1
-1
@@ -5,7 +5,7 @@
|
|||||||
$version = GetVersion $majorWithReleaseVersion
|
$version = GetVersion $majorWithReleaseVersion
|
||||||
$signAssemblies = $false
|
$signAssemblies = $false
|
||||||
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
$signKeyPath = "D:\Development\Releases\newtonsoft.snk"
|
||||||
$buildDocumentation = $false
|
$buildDocumentation = $true
|
||||||
$buildNuGet = $false
|
$buildNuGet = $false
|
||||||
|
|
||||||
$baseDir = resolve-path ..
|
$baseDir = resolve-path ..
|
||||||
|
|||||||
@@ -0,0 +1,41 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="Examples" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>Json.NET has the ability to conditionally serialize properties by placing a ShouldSerialize method on a class.
|
||||||
|
This funtionality is similar to the <externalLink>
|
||||||
|
<linkText>XmlSerializer ShouldSerialize feature</linkText>
|
||||||
|
<linkUri>http://msdn.microsoft.com/en-us/library/53b8022e.aspx</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink>.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>ShouldSerialize</title>
|
||||||
|
<content>
|
||||||
|
<para>To conditionally serialize a property add a boolean method with the same name as the property and then prefixed the method name
|
||||||
|
with ShouldSerialize. The result of the method determines whether the property is serialized. If the method returns true then the
|
||||||
|
property will be serialized, if it returns false and the property will be skipped.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="EmployeeShouldSerializeExample" title="Employee class with a ShouldSerialize method" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeClassTest" title="ShouldSerialize output" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>IContractResolver</title>
|
||||||
|
<content>
|
||||||
|
<para>ShouldSerialize can also be set using an <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>.
|
||||||
|
Conditionally serializing a property using an IContractResolver is useful if you don't want to place a ShouldSerialize method on a class
|
||||||
|
or you didn't declare the class and are unable to.</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.JsonSerializer</codeEntityReference>
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||||
|
<codeEntityReference>P:Newtonsoft.Json.Serialization.JsonProperty.ShouldSerialize</codeEntityReference>
|
||||||
|
</relatedTopics>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,70 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="Serializer" 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>Anything that can be set on an object, collection, property, etc, using attributes or methods to control serialization
|
||||||
|
can also be set using an IContractResolver.</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 IContractResolver Examples</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
||||||
|
|
||||||
|
<para>This example sets a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> for a type
|
||||||
|
using an IContractResolver. Using a contract resolver here is useful because DateTime is not your own type and it is not possible to place a JsonConverterAttribute on it.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
|
||||||
|
|
||||||
|
<para>This example sets up <externalLink>
|
||||||
|
<linkText>conditional serialization for a property</linkText>
|
||||||
|
<linkUri>ConditionalProperties.htm</linkUri>
|
||||||
|
<linkTarget>_self</linkTarget>
|
||||||
|
</externalLink> using an IContractResolver. This is useful if you want to conditionally serialize a property but don't want to add additional methods to your type.</para>
|
||||||
|
</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>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="CustomContractResolver" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example creates a custom <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||||
|
that only serializes a type's properties that begin with a specified character.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomContractResolver.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomContractResolver.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="CustomJsonConverter" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example creates a custom <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||||
|
that overrides serialization to add a keys property.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomJsonConverter.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomJsonConverter.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="CustomTraceWriter" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example creates a custom <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
||||||
|
that writes to
|
||||||
|
<externalLink>
|
||||||
|
<linkText>NLog</linkText>
|
||||||
|
<linkUri>http://nlog-project.org/</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink>.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomTraceWriter.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomTraceWriter.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DataContractAndDataMember" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example shows how .NET Framework attributes such as
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.DataContractAttribute</codeEntityReference>,
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.DataMemberAttribute</codeEntityReference> and
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.NonSerializedAttribute</codeEntityReference>
|
||||||
|
can be used with Json.NET instead of Json.NET's own attributes.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomContractResolver.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\CustomContractResolver.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DefaultValueAttributeIgnore" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:System.ComponentModel.DefaultValueAttribute</codeEntityReference>
|
||||||
|
to override the default value for a property and exclude it from serialization using
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.DefaultValueHandling</codeEntityReference>.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DefaultValueAttributeIgnore.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DefaultValueAttributeIgnore.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DefaultValueHandlingIgnore" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.DefaultValueHandling</codeEntityReference> setting to
|
||||||
|
not serialize properties with a default value.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DefaultValueHandlingIgnore.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DefaultValueHandlingIgnore.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeAnonymousType" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON into an anonymous type.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeAnonymousType.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeCollection" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON into a collection.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeCollection.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeConstructorHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.ConstructorHandling</codeEntityReference> setting to
|
||||||
|
successfully deserialize the class using its non-public constructor.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeConstructorHandling.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeConstructorHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeCustomCreationConverter" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example creates a class that inherits from <codeEntityReference>T:Newtonsoft.Json.CustomCreationConverter`1</codeEntityReference>
|
||||||
|
that instantiates Employee instances for the Person type.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeCustomCreationConverter.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeCustomCreationConverter.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeDataSet" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON to a <codeEntityReference>T:System.Data.DataSet</codeEntityReference>.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeDataSet.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeDictionary" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON into a dictionary.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeDictionary.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeMissingMemberHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example attempts to deserialize JSON with <codeEntityReference>T:Newtonsoft.Json.MissingMemberHandling</codeEntityReference>
|
||||||
|
set to error and a JSON property that doesn't match to a member, causing an exception.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeMissingMemberHandling.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeMissingMemberHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeObject" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON to an object.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeObject.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeObject.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeObjectCreationHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON with <codeEntityReference>T:Newtonsoft.Json.ObjectCreationHandling</codeEntityReference>
|
||||||
|
set to Replace so that collection values aren't duplicated.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeObjectCreationHandling.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeObjectCreationHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="DeserializeWithJsonSerializerFromFile" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example deserializes JSON retrieved from a file.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeWithJsonSerializerFromFile.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\DeserializeWithJsonSerializerFromFile.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="ErrorHandlingAttribute" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.OnErrorAttribute</codeEntityReference> to ignore the exception thrown setting the Roles property.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\ErrorHandlingAttribute.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\ErrorHandlingAttribute.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="ErrorHandlingEvent" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>P:Newtonsoft.Json.JsonSerializerSettings.Error</codeEntityReference> event
|
||||||
|
to ignore the exceptions thrown from the invalid date strings.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\ErrorHandlingEvent.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonConverterAttributeClass" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>
|
||||||
|
to specify that a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||||
|
should be used when serializing and deserializing a class.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonConverterAttributeClass.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonConverterAttributeClass.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonConverterAttributeProperty" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>
|
||||||
|
to specify that a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||||
|
should be used when serializing and deserializing a property.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonConverterAttributeProperty.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonConverterAttributeProperty.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonObjectAttributeOptIn" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses
|
||||||
|
<codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference>
|
||||||
|
and <codeEntityReference>T:Newtonsoft.Json.MemberSerialization</codeEntityReference> to specify that
|
||||||
|
only properties that have been explicitly specified with <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
should be serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonObjectAttributeOptIn.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonObjectAttributeOptIn.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonObjectAttributeOverrideIEnumerable" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference>
|
||||||
|
to serialize a class that implements <codeEntityReference>T:System.IEnumerable`1</codeEntityReference> as
|
||||||
|
a JSON object instead of a JSON array.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonObjectAttributeOverrideIEnumerable.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonObjectAttributeOverrideIEnumerable.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonPropertyItemLevelSetting" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
to change how the property value's items are serialized,
|
||||||
|
e.g. setting ItemIsReference to true on a property with a collection will serialize all the collection's items
|
||||||
|
with reference tracking enabled.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyItemLevelSetting.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyItemLevelSetting.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonPropertyName" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
to change the names of properties when they are serialized to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyName.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyName.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonPropertyOrder" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
to order of properties when they are serialized to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyOrder.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyOrder.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonPropertyPropertyLevelSetting" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
to change how the property value is serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyPropertyLevelSetting.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyPropertyLevelSetting.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonPropertyRequired" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
|
||||||
|
to set <codeEntityReference>T:Newtonsoft.Json.Required</codeEntityReference> which is used during deserialization
|
||||||
|
to validate the presence of required JSON properties.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyRequired.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\JsonPropertyRequired.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="MaxDepth" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>P:Newtonsoft.Json.JsonSerializerSettings.MaxDepth</codeEntityReference> setting to constrain JSON
|
||||||
|
to a maximum depth when deserializing.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\MaxDepth.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="NullValueHandlingIgnore" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes an object to JSON with <codeEntityReference>T:Newtonsoft.Json.NullValueHandling</codeEntityReference>
|
||||||
|
set to Ignore so that properties with a default value aren't included in the JSON result.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\NullValueHandlingIgnore.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\NullValueHandlingIgnore.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="PopulateObject" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example populates an existing object instance with values from JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PopulateObject.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PopulateObject.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="PreserveReferencesHandlingObject" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example shows how the <codeEntityReference>T:Newtonsoft.Json.PreserveReferencesHandling</codeEntityReference>
|
||||||
|
setting can be used to serialize values by reference instead of by value.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PreserveReferencesHandlingObject.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PreserveReferencesHandlingObject.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="PropertyJsonIgnore" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.JsonIgnoreAttribute</codeEntityReference>
|
||||||
|
to exclude a property from serialization.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PropertyJsonIgnore.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\PropertyJsonIgnore.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="ReferenceLoopHandlingIgnore" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example sets <codeEntityReference>T:Newtonsoft.Json.ReferenceLoopHandling</codeEntityReference>
|
||||||
|
to Ignore so that looping values are excluded from serialization instead of throwing an exception.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\ReferenceLoopHandlingIgnore.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\ReferenceLoopHandlingIgnore.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializationCallbackAttributes" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses serialization callback attributes
|
||||||
|
(<codeEntityReference>T:System.Runtime.Serialization.OnSerializingAttribute</codeEntityReference>,
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.OnSerializedAttribute</codeEntityReference>,
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializingAttribute</codeEntityReference>,
|
||||||
|
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializedAttribute</codeEntityReference>)
|
||||||
|
to manipulate an object before and after its serialization and deserialization.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializationCallbackAttributes.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializationCallbackAttributes.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeCollection" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes a collection to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeCollection.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeConditionalProperty" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses a conditional property to exclude a property from serialization.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeConditionalProperty.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeConditionalProperty.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeContractResolver" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses a custom <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
||||||
|
to modify how objects are serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeContractResolver.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeContractResolver.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeDataSet" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes a DataSet to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeDataSet.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeDateFormatHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.DateFormatHandling</codeEntityReference>
|
||||||
|
setting to control how <codeEntityReference>T:System.DateTime</codeEntityReference> and <codeEntityReference>T:System.DateTimeOffset</codeEntityReference> are serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeDateFormatHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeDateTimeZoneHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.DateTimeZoneHandling</codeEntityReference>
|
||||||
|
setting to control how <codeEntityReference>T:System.DateTime</codeEntityReference> and <codeEntityReference>T:System.DateTimeOffset</codeEntityReference> are serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeDateTimeZoneHandling.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeDateTimeZoneHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeDictionary" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes a dictionary to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeDictionary.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeObject" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes an object to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeObject.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeObject.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeRawJson" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses <codeEntityReference>T:Newtonsoft.Json.Linq.JRaw</codeEntityReference>
|
||||||
|
properties to serialize raw text to JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeRawJson.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeRawJson.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeSerializationBinder" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example creates a custom <codeEntityReference>T:System.RunTime.Serialization.SerializationBinder</codeEntityReference>
|
||||||
|
that writes only the type name when including type data in JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeSerializationBinder.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeSerializationBinder.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeTypeNameHandling" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses the <codeEntityReference>T:Newtonsoft.Json.TypeNameHandling</codeEntityReference>
|
||||||
|
setting to include type information when serializing JSON and read type information so that the create types are created when deserializing JSON.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeTypeNameHandling.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeTypeNameHandling.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeUnindentedJson" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes an object to JSON without any formatting or indentation whitespace.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeUnindentedJson.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeUnindentedJson.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeWithJsonConverters" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
|
||||||
|
to customize how JSON is serialized.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeWithJsonConverters.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="SerializeWithJsonSerializerToFile" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example serializes JSON to a file.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeWithJsonSerializerToFile.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\SerializeWithJsonSerializerToFile.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="TraceWriter" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>This example uses an <codeEntityReference>T:Newtonsoft.Json.Serialization.ITraceWriter</codeEntityReference>
|
||||||
|
to log debug information from serialization.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Example</title>
|
||||||
|
<content>
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\TraceWriter.cs" region="Types" title="Types" />
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\Examples\Serializer\TraceWriter.cs" region="Usage" title="Usage" />
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
+55
-2
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Topics>
|
<Topics>
|
||||||
<Topic id="Introduction" visible="True" isDefault="true" />
|
<Topic id="Introduction" visible="True" isDefault="true" />
|
||||||
<Topic id="SerializingJSON" visible="True" isExpanded="true" title="Serializing and Deserializing JSON">
|
<Topic id="SerializingJSON" visible="True" title="Serializing and Deserializing JSON">
|
||||||
<Topic id="SerializationSettings" visible="True" title="Serialization Settings" />
|
<Topic id="SerializationSettings" visible="True" title="Serialization Settings" />
|
||||||
<Topic id="SerializationGuide" visible="True" title="Serialization Guide" />
|
<Topic id="SerializationGuide" visible="True" title="Serialization Guide" />
|
||||||
<Topic id="SerializationAttributes" visible="True" title="Serialization Attributes" />
|
<Topic id="SerializationAttributes" visible="True" title="Serialization Attributes" />
|
||||||
@@ -15,7 +15,7 @@
|
|||||||
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
||||||
<Topic id="ConditionalProperties" visible="True" title="Conditional Property Serialization" />
|
<Topic id="ConditionalProperties" visible="True" title="Conditional Property Serialization" />
|
||||||
<Topic id="ContractResolver" visible="True" title="Serialization using ContractResolver" />
|
<Topic id="ContractResolver" visible="True" title="Serialization using ContractResolver" />
|
||||||
<Topic id="SerializationTracing" visible="True" isSelected="true" title="Debugging with Serialization Tracing" />
|
<Topic id="SerializationTracing" visible="True" title="Debugging with Serialization Tracing" />
|
||||||
</Topic>
|
</Topic>
|
||||||
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
||||||
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
||||||
@@ -29,4 +29,57 @@
|
|||||||
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
||||||
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
|
<Topic id="JsonNetVsDotNetSerializers" visible="True" title="Json.NET vs .NET Serializers" />
|
||||||
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
|
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
|
||||||
|
<Topic id="Examples" visible="True" isExpanded="true">
|
||||||
|
<Topic id="Serializer" visible="True" isExpanded="true">
|
||||||
|
<Topic id="CustomContractResolver" visible="True" title="Custom Contract Resolver" />
|
||||||
|
<Topic id="CustomJsonConverter" visible="True" />
|
||||||
|
<Topic id="CustomTraceWriter" visible="True" />
|
||||||
|
<Topic id="DataContractAndDataMember" visible="True" />
|
||||||
|
<Topic id="DefaultValueAttributeIgnore" visible="True" />
|
||||||
|
<Topic id="DefaultValueHandlingIgnore" visible="True" />
|
||||||
|
<Topic id="DeserializeAnonymousType" visible="True" />
|
||||||
|
<Topic id="DeserializeCollection" visible="True" />
|
||||||
|
<Topic id="DeserializeConstructorHandling" visible="True" />
|
||||||
|
<Topic id="DeserializeCustomCreationConverter" visible="True" />
|
||||||
|
<Topic id="DeserializeDataSet" visible="True" />
|
||||||
|
<Topic id="DeserializeDictionary" visible="True" />
|
||||||
|
<Topic id="DeserializeMissingMemberHandling" visible="True" />
|
||||||
|
<Topic id="DeserializeObject" visible="True" />
|
||||||
|
<Topic id="DeserializeObjectCreationHandling" visible="True" isSelected="true" />
|
||||||
|
<Topic id="DeserializeWithJsonSerializerFromFile" visible="True" />
|
||||||
|
<Topic id="ErrorHandlingAttribute" visible="True" />
|
||||||
|
<Topic id="ErrorHandlingEvent" visible="True" />
|
||||||
|
<Topic id="JsonConverterAttributeClass" visible="True" />
|
||||||
|
<Topic id="JsonConverterAttributeProperty" visible="True" />
|
||||||
|
<Topic id="JsonObjectAttributeOptIn" visible="True" />
|
||||||
|
<Topic id="JsonObjectAttributeOverrideIEnumerable" visible="True" />
|
||||||
|
<Topic id="JsonPropertyItemLevelSetting" visible="True" />
|
||||||
|
<Topic id="JsonPropertyName" visible="True" />
|
||||||
|
<Topic id="JsonPropertyOrder" visible="True" />
|
||||||
|
<Topic id="JsonPropertyPropertyLevelSetting" visible="True" />
|
||||||
|
<Topic id="JsonPropertyRequired" visible="True" />
|
||||||
|
<Topic id="MaxDepth" visible="True" />
|
||||||
|
<Topic id="NullValueHandlingIgnore" visible="True" />
|
||||||
|
<Topic id="PopulateObject" visible="True" />
|
||||||
|
<Topic id="PreserveReferencesHandlingObject" visible="True" />
|
||||||
|
<Topic id="PropertyJsonIgnore" visible="True" />
|
||||||
|
<Topic id="ReferenceLoopHandlingIgnore" visible="True" />
|
||||||
|
<Topic id="SerializationCallbackAttributes" visible="True" />
|
||||||
|
<Topic id="SerializeCollection" visible="True" />
|
||||||
|
<Topic id="SerializeConditionalProperty" visible="True" />
|
||||||
|
<Topic id="SerializeContractResolver" visible="True" />
|
||||||
|
<Topic id="SerializeDataSet" visible="True" />
|
||||||
|
<Topic id="SerializeDateFormatHandling" visible="True" />
|
||||||
|
<Topic id="SerializeDateTimeZoneHandling" visible="True" />
|
||||||
|
<Topic id="SerializeDictionary" visible="True" />
|
||||||
|
<Topic id="SerializeObject" visible="True" />
|
||||||
|
<Topic id="SerializeRawJson" visible="True" />
|
||||||
|
<Topic id="SerializeSerializationBinder" visible="True" />
|
||||||
|
<Topic id="SerializeTypeNameHandling" visible="True" />
|
||||||
|
<Topic id="SerializeUnindentedJson" visible="True" />
|
||||||
|
<Topic id="SerializeWithJsonConverters" visible="True" />
|
||||||
|
<Topic id="SerializeWithJsonSerializerToFile" visible="True" />
|
||||||
|
<Topic id="TraceWriter" visible="True" />
|
||||||
|
</Topic>
|
||||||
|
</Topic>
|
||||||
</Topics>
|
</Topics>
|
||||||
@@ -137,6 +137,57 @@
|
|||||||
<Content Include="donate.gif" />
|
<Content Include="donate.gif" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="Examples\Serializer\TraceWriter.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeWithJsonSerializerToFile.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeWithJsonConverters.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeUnindentedJson.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeTypeNameHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeSerializationBinder.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeRawJson.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeObject.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeDictionary.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeDateTimeZoneHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeDateFormatHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeDataSet.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeContractResolver.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeConditionalProperty.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializeCollection.aml" />
|
||||||
|
<None Include="Examples\Serializer\SerializationCallbackAttributes.aml" />
|
||||||
|
<None Include="Examples\Serializer\ReferenceLoopHandlingIgnore.aml" />
|
||||||
|
<None Include="Examples\Serializer\PropertyJsonIgnore.aml" />
|
||||||
|
<None Include="Examples\Serializer\PreserveReferencesHandlingObject.aml" />
|
||||||
|
<None Include="Examples\Serializer\PopulateObject.aml" />
|
||||||
|
<None Include="Examples\Serializer\NullValueHandlingIgnore.aml" />
|
||||||
|
<None Include="Examples\Serializer\MaxDepth.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonPropertyRequired.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonPropertyPropertyLevelSetting.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonPropertyOrder.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonPropertyName.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonPropertyItemLevelSetting.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonObjectAttributeOverrideIEnumerable.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonObjectAttributeOptIn.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonConverterAttributeProperty.aml" />
|
||||||
|
<None Include="Examples\Serializer\JsonConverterAttributeClass.aml" />
|
||||||
|
<None Include="Examples\Serializer\ErrorHandlingEvent.aml" />
|
||||||
|
<None Include="Examples\Serializer\ErrorHandlingAttribute.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeWithJsonSerializerFromFile.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeObjectCreationHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeObject.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeMissingMemberHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeDictionary.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeDataSet.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeCustomCreationConverter.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeConstructorHandling.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeCollection.aml" />
|
||||||
|
<None Include="Examples\Serializer\DeserializeAnonymousType.aml" />
|
||||||
|
<None Include="Examples\Serializer\DefaultValueHandlingIgnore.aml" />
|
||||||
|
<None Include="Examples\Serializer\DefaultValueAttributeIgnore.aml" />
|
||||||
|
<None Include="Examples\Serializer\DataContractAndDataMember.aml" />
|
||||||
|
<None Include="Examples\Serializer\CustomTraceWriter.aml" />
|
||||||
|
<None Include="Examples\Serializer\CustomJsonConverter.aml" />
|
||||||
|
<None Include="Examples\Serializer\CustomContractResolver.aml" />
|
||||||
|
<None Include="Examples\Serializer.aml" />
|
||||||
|
<None Include="Examples\Examples.aml" />
|
||||||
<None Include="SerializationTracing.aml" />
|
<None Include="SerializationTracing.aml" />
|
||||||
<None Include="JsonNetVsDotNetSerializers.aml" />
|
<None Include="JsonNetVsDotNetSerializers.aml" />
|
||||||
<None Include="JsonNetVsWindowsDataJson.aml" />
|
<None Include="JsonNetVsWindowsDataJson.aml" />
|
||||||
@@ -191,6 +242,10 @@
|
|||||||
<AlternateText>logo</AlternateText>
|
<AlternateText>logo</AlternateText>
|
||||||
</Image>
|
</Image>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Examples\Serializer\" />
|
||||||
|
<Folder Include="Examples\" />
|
||||||
|
</ItemGroup>
|
||||||
<!-- Import the SHFB build targets -->
|
<!-- Import the SHFB build targets -->
|
||||||
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
<Import Project="$(SHFBROOT)\SandcastleHelpFileBuilder.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -22,14 +22,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
|||||||
{
|
{
|
||||||
string json = @"[
|
string json = @"[
|
||||||
{
|
{
|
||||||
""Title"": ""Json.NET is awesome!"",
|
'Title': 'Json.NET is awesome!',
|
||||||
""Author"": {
|
'Author': {
|
||||||
""Name"": ""James Newton-King"",
|
'Name': 'James Newton-King',
|
||||||
""Twitter"": ""@JamesNK"",
|
'Twitter': '@JamesNK',
|
||||||
""Picture"": ""/jamesnk.png""
|
'Picture': '/jamesnk.png'
|
||||||
},
|
},
|
||||||
""Date"": ""2013-01-23T19:30:00"",
|
'Date': '2013-01-23T19:30:00',
|
||||||
""BodyHtml"": ""<h3>Title!</h3>\r\n<p>Content!</p>""
|
'BodyHtml': '<h3>Title!</h3>\r\n<p>Content!</p>'
|
||||||
}
|
}
|
||||||
]";
|
]";
|
||||||
|
|
||||||
|
|||||||
@@ -11,12 +11,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
|||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""channel"": {
|
'channel': {
|
||||||
""title"": ""Star Wars"",
|
'title': 'Star Wars',
|
||||||
""link"": ""http://www.starwars.com"",
|
'link': 'http://www.starwars.com',
|
||||||
""description"": ""Star Wars blog."",
|
'description': 'Star Wars blog.',
|
||||||
""obsolete"": ""Obsolete value"",
|
'obsolete': 'Obsolete value',
|
||||||
""item"": []
|
'item': []
|
||||||
}
|
}
|
||||||
}";
|
}";
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
|||||||
Console.WriteLine(t3.Type);
|
Console.WriteLine(t3.Type);
|
||||||
// Null
|
// Null
|
||||||
|
|
||||||
JToken t4 = JToken.Parse(@"""A string!""");
|
JToken t4 = JToken.Parse(@"'A string!'");
|
||||||
|
|
||||||
Console.WriteLine(t4.Type);
|
Console.WriteLine(t4.Type);
|
||||||
// String
|
// String
|
||||||
|
|||||||
@@ -13,14 +13,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
|||||||
{
|
{
|
||||||
string json = @"[
|
string json = @"[
|
||||||
{
|
{
|
||||||
""Title"": ""Json.NET is awesome!"",
|
'Title': 'Json.NET is awesome!',
|
||||||
""Author"": {
|
'Author': {
|
||||||
""Name"": ""James Newton-King"",
|
'Name': 'James Newton-King',
|
||||||
""Twitter"": ""@JamesNK"",
|
'Twitter': '@JamesNK',
|
||||||
""Picture"": ""/jamesnk.png""
|
'Picture': '/jamesnk.png'
|
||||||
},
|
},
|
||||||
""Date"": ""2013-01-23T19:30:00"",
|
'Date': '2013-01-23T19:30:00',
|
||||||
""BodyHtml"": ""<h3>Title!</h3>\r\n<p>Content!</p>""
|
'BodyHtml': '<h3>Title!</h3>\r\n<p>Content!</p>'
|
||||||
}
|
}
|
||||||
]";
|
]";
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Linq
|
|||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""d"": [
|
'd': [
|
||||||
{
|
{
|
||||||
""Name"": ""John Smith""
|
'Name': 'John Smith'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
""Name"": ""Mike Smith""
|
'Name': 'Mike Smith'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}";
|
}";
|
||||||
|
|||||||
@@ -15,33 +15,33 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Schema
|
|||||||
JsonSchemaResolver resolver = new JsonSchemaResolver();
|
JsonSchemaResolver resolver = new JsonSchemaResolver();
|
||||||
|
|
||||||
schemaJson = @"{
|
schemaJson = @"{
|
||||||
""id"": ""person"",
|
'id': 'person',
|
||||||
""type"": ""object"",
|
'type': 'object',
|
||||||
""properties"": {
|
'properties': {
|
||||||
""name"": {""type"":""string""},
|
'name': {'type':'string'},
|
||||||
""age"": {""type"":""integer""}
|
'age': {'type':'integer'}
|
||||||
}
|
}
|
||||||
}";
|
}";
|
||||||
|
|
||||||
JsonSchema personSchema = JsonSchema.Parse(schemaJson, resolver);
|
JsonSchema personSchema = JsonSchema.Parse(schemaJson, resolver);
|
||||||
|
|
||||||
schemaJson = @"{
|
schemaJson = @"{
|
||||||
""id"": ""employee"",
|
'id': 'employee',
|
||||||
""type"": ""object"",
|
'type': 'object',
|
||||||
""extends"": {""$ref"":""person""},
|
'extends': {'$ref':'person'},
|
||||||
""properties"": {
|
'properties': {
|
||||||
""salary"": {""type"":""number""},
|
'salary': {'type':'number'},
|
||||||
""jobTitle"": {""type"":""string""}
|
'jobTitle': {'type':'string'}
|
||||||
}
|
}
|
||||||
}";
|
}";
|
||||||
|
|
||||||
JsonSchema employeeSchema = JsonSchema.Parse(schemaJson, resolver);
|
JsonSchema employeeSchema = JsonSchema.Parse(schemaJson, resolver);
|
||||||
|
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""name"": ""James"",
|
'name': 'James',
|
||||||
""age"": 29,
|
'age': 29,
|
||||||
""salary"": 9000.01,
|
'salary': 9000.01,
|
||||||
""jobTitle"": ""Junior Vice President""
|
'jobTitle': 'Junior Vice President'
|
||||||
}";
|
}";
|
||||||
|
|
||||||
JObject employee = JObject.Parse(json);
|
JObject employee = JObject.Parse(json);
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class CustomContractResolver
|
public class CustomContractResolver
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class DynamicContractResolver : DefaultContractResolver
|
public class DynamicContractResolver : DefaultContractResolver
|
||||||
{
|
{
|
||||||
private readonly char _startingWithChar;
|
private readonly char _startingWithChar;
|
||||||
@@ -38,9 +39,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
get { return FirstName + " " + LastName; }
|
get { return FirstName + " " + LastName; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Person person = new Person
|
Person person = new Person
|
||||||
{
|
{
|
||||||
FirstName = "Dennis",
|
FirstName = "Dennis",
|
||||||
@@ -63,6 +66,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// {
|
// {
|
||||||
// "LastName": "Deepwater-Diver"
|
// "LastName": "Deepwater-Diver"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class CustomJsonConverter
|
public class CustomJsonConverter
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class KeysJsonConverter : JsonConverter
|
public class KeysJsonConverter : JsonConverter
|
||||||
{
|
{
|
||||||
private Type[] _types;
|
private Type[] _types;
|
||||||
@@ -58,9 +59,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public string LastName { get; set; }
|
public string LastName { get; set; }
|
||||||
public IList<string> Roles { get; set; }
|
public IList<string> Roles { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Employee employee = new Employee
|
Employee employee = new Employee
|
||||||
{
|
{
|
||||||
FirstName = "James",
|
FirstName = "James",
|
||||||
@@ -91,6 +94,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(newEmployee.FirstName);
|
Console.WriteLine(newEmployee.FirstName);
|
||||||
// James
|
// James
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class CustomTraceWriter
|
public class CustomTraceWriter
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class NLogTraceWriter : ITraceWriter
|
public class NLogTraceWriter : ITraceWriter
|
||||||
{
|
{
|
||||||
private static readonly Logger Logger = LogManager.GetLogger("NLogTraceWriter");
|
private static readonly Logger Logger = LogManager.GetLogger("NLogTraceWriter");
|
||||||
@@ -49,9 +50,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
IList<string> countries = new List<string>
|
IList<string> countries = new List<string>
|
||||||
{
|
{
|
||||||
"New Zealand",
|
"New Zealand",
|
||||||
@@ -72,6 +75,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Denmark",
|
// "Denmark",
|
||||||
// "China"
|
// "China"
|
||||||
// ]
|
// ]
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DataContractAndDataMember
|
public class DataContractAndDataMember
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
[DataContract]
|
[DataContract]
|
||||||
public class File
|
public class File
|
||||||
{
|
{
|
||||||
@@ -20,9 +21,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[DataMember]
|
[DataMember]
|
||||||
public int Size { get; set; }
|
public int Size { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
File file = new File
|
File file = new File
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@@ -37,6 +40,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "ImportantLegalDocuments.docx",
|
// "Name": "ImportantLegalDocuments.docx",
|
||||||
// "Size": 51200
|
// "Size": 51200
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DefaultValueAttributeIgnore
|
public class DefaultValueAttributeIgnore
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Customer
|
public class Customer
|
||||||
{
|
{
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
@@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
get { return FirstName + " " + LastName; }
|
get { return FirstName + " " + LastName; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Customer customer = new Customer();
|
Customer customer = new Customer();
|
||||||
|
|
||||||
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented);
|
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(customer, Formatting.Indented);
|
||||||
@@ -40,6 +43,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(jsonIgnoreDefaultValues);
|
Console.WriteLine(jsonIgnoreDefaultValues);
|
||||||
// {}
|
// {}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DefaultValueHandlingIgnore
|
public class DefaultValueHandlingIgnore
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Person
|
public class Person
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public Person Partner { get; set; }
|
public Person Partner { get; set; }
|
||||||
public decimal? Salary { get; set; }
|
public decimal? Salary { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Person person = new Person();
|
Person person = new Person();
|
||||||
|
|
||||||
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented);
|
string jsonIncludeDefaultValues = JsonConvert.SerializeObject(person, Formatting.Indented);
|
||||||
@@ -36,6 +39,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(jsonIgnoreDefaultValues);
|
Console.WriteLine(jsonIgnoreDefaultValues);
|
||||||
// {}
|
// {}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -9,7 +9,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
string json = @"{""Name"":""James""}";
|
#region Usage
|
||||||
|
string json = @"{'Name':'James'}";
|
||||||
|
|
||||||
var customerDefinition = new {Name = ""};
|
var customerDefinition = new {Name = ""};
|
||||||
|
|
||||||
@@ -17,6 +18,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(customer.Name);
|
Console.WriteLine(customer.Name);
|
||||||
// James
|
// James
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -9,12 +9,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
string json = @"[""Starcraft"",""Halo"",""Legend of Zelda""]";
|
#region Usage
|
||||||
|
string json = @"['Starcraft','Halo','Legend of Zelda']";
|
||||||
|
|
||||||
List<string> videogames = JsonConvert.DeserializeObject<List<string>>(json);
|
List<string> videogames = JsonConvert.DeserializeObject<List<string>>(json);
|
||||||
|
|
||||||
Console.WriteLine(string.Join(", ", videogames));
|
Console.WriteLine(string.Join(", ", videogames));
|
||||||
// Starcraft, Halo, Legend of Zelda
|
// Starcraft, Halo, Legend of Zelda
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeConstructorHandling
|
public class DeserializeConstructorHandling
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Website
|
public class Website
|
||||||
{
|
{
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
@@ -24,10 +25,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
Url = website.Url;
|
Url = website.Url;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
string json = @"{""Url"":""http://www.google.com""}";
|
#region Usage
|
||||||
|
string json = @"{'Url':'http://www.google.com'}";
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -46,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(website.Url);
|
Console.WriteLine(website.Url);
|
||||||
// http://www.google.com
|
// http://www.google.com
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-5
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeCustomCreationConverter
|
public class DeserializeCustomCreationConverter
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Person
|
public class Person
|
||||||
{
|
{
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
@@ -28,15 +29,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
return new Employee();
|
return new Employee();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Department"": ""Furniture"",
|
'Department': 'Furniture',
|
||||||
""JobTitle"": ""Carpenter"",
|
'JobTitle': 'Carpenter',
|
||||||
""FirstName"": ""John"",
|
'FirstName': 'John',
|
||||||
""LastName"": ""Joinery"",
|
'LastName': 'Joinery',
|
||||||
""BirthDate"": ""1983-02-02T00:00:00""
|
'BirthDate': '1983-02-02T00:00:00'
|
||||||
}";
|
}";
|
||||||
|
|
||||||
Person person = JsonConvert.DeserializeObject<Person>(json, new PersonConverter());
|
Person person = JsonConvert.DeserializeObject<Person>(json, new PersonConverter());
|
||||||
@@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(employee.JobTitle);
|
Console.WriteLine(employee.JobTitle);
|
||||||
// Capenter
|
// Capenter
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,15 +11,16 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Table1"": [
|
'Table1': [
|
||||||
{
|
{
|
||||||
""id"": 0,
|
'id': 0,
|
||||||
""item"": ""item 0""
|
'item': 'item 0'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
""id"": 1,
|
'id': 1,
|
||||||
""item"": ""item 1""
|
'item': 'item 1'
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}";
|
}";
|
||||||
@@ -37,6 +38,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
}
|
}
|
||||||
// 0 - item 0
|
// 0 - item 0
|
||||||
// 1 - item 1
|
// 1 - item 1
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
-2
@@ -9,9 +9,10 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""href"": ""/account/login.aspx"",
|
'href': '/account/login.aspx',
|
||||||
""target"": ""_blank""
|
'target': '_blank'
|
||||||
}";
|
}";
|
||||||
|
|
||||||
Dictionary<string, string> htmlAttributes = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
|
Dictionary<string, string> htmlAttributes = JsonConvert.DeserializeObject<Dictionary<string, string>>(json);
|
||||||
@@ -21,6 +22,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(htmlAttributes["target"]);
|
Console.WriteLine(htmlAttributes["target"]);
|
||||||
// _blank
|
// _blank
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -7,18 +7,21 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeMissingMemberHandling
|
public class DeserializeMissingMemberHandling
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
public bool Deleted { get; set; }
|
public bool Deleted { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""FullName"": ""Dan Deleted"",
|
'FullName': 'Dan Deleted',
|
||||||
""Deleted"": true,
|
'Deleted': true,
|
||||||
""DeletedDate"": ""2013-01-20T00:00:00""
|
'DeletedDate': '2013-01-20T00:00:00'
|
||||||
}";
|
}";
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -28,10 +31,12 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
MissingMemberHandling = MissingMemberHandling.Error
|
MissingMemberHandling = MissingMemberHandling.Error
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch (JsonSerializationException)
|
catch (JsonSerializationException ex)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine(ex.Message);
|
||||||
// Could not find member 'DeletedDate' on object of type 'Account'. Path 'DeletedDate', line 4, position 23.
|
// Could not find member 'DeletedDate' on object of type 'Account'. Path 'DeletedDate', line 4, position 23.
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeObject
|
public class DeserializeObject
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
@@ -14,16 +15,18 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public DateTime CreatedDate { get; set; }
|
public DateTime CreatedDate { get; set; }
|
||||||
public IList<string> Roles { get; set; }
|
public IList<string> Roles { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Email"": ""james@example.com"",
|
'Email': 'james@example.com',
|
||||||
""Active"": true,
|
'Active': true,
|
||||||
""CreatedDate"": ""2013-01-20T00:00:00Z"",
|
'CreatedDate': '2013-01-20T00:00:00Z',
|
||||||
""Roles"": [
|
'Roles': [
|
||||||
""User"",
|
'User',
|
||||||
""Admin""
|
'Admin'
|
||||||
]
|
]
|
||||||
}";
|
}";
|
||||||
|
|
||||||
@@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(account.Email);
|
Console.WriteLine(account.Email);
|
||||||
// james@example.com
|
// james@example.com
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+9
-5
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeObjectCreationHandling
|
public class DeserializeObjectCreationHandling
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class UserViewModel
|
public class UserViewModel
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -22,15 +23,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Name"": ""James"",
|
'Name': 'James',
|
||||||
""Offices"": [
|
'Offices': [
|
||||||
""Auckland"",
|
'Auckland',
|
||||||
""Wellington"",
|
'Wellington',
|
||||||
""Christchurch""
|
'Christchurch'
|
||||||
]
|
]
|
||||||
}";
|
}";
|
||||||
|
|
||||||
@@ -59,6 +62,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// Auckland
|
// Auckland
|
||||||
// Wellington
|
// Wellington
|
||||||
// Christchurch
|
// Christchurch
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -9,14 +9,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class DeserializeWithJsonSerializerFromFile
|
public class DeserializeWithJsonSerializerFromFile
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Movie
|
public class Movie
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int Year { get; set; }
|
public int Year { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
// read file into a string and deserialize JSON to a type
|
// read file into a string and deserialize JSON to a type
|
||||||
Movie movie1 = JsonConvert.DeserializeObject<Movie>(File.ReadAllText(@"c:\movie.json"));
|
Movie movie1 = JsonConvert.DeserializeObject<Movie>(File.ReadAllText(@"c:\movie.json"));
|
||||||
|
|
||||||
@@ -26,6 +29,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
JsonSerializer serializer = new JsonSerializer();
|
JsonSerializer serializer = new JsonSerializer();
|
||||||
Movie movie2 = (Movie)serializer.Deserialize(file, typeof (Movie));
|
Movie movie2 = (Movie)serializer.Deserialize(file, typeof (Movie));
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class ErrorHandlingAttribute
|
public class ErrorHandlingAttribute
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Employee
|
public class Employee
|
||||||
{
|
{
|
||||||
private List<string> _roles;
|
private List<string> _roles;
|
||||||
@@ -34,9 +35,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
errorContext.Handled = true;
|
errorContext.Handled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Employee person = new Employee
|
Employee person = new Employee
|
||||||
{
|
{
|
||||||
Name = "George Michael Bluth",
|
Name = "George Michael Bluth",
|
||||||
@@ -53,6 +56,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Age": 16,
|
// "Age": 16,
|
||||||
// "Title": "Mister Manager"
|
// "Title": "Mister Manager"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
List<string> errors = new List<string>();
|
List<string> errors = new List<string>();
|
||||||
|
|
||||||
List<DateTime> c = JsonConvert.DeserializeObject<List<DateTime>>(@"[
|
List<DateTime> c = JsonConvert.DeserializeObject<List<DateTime>>(@"[
|
||||||
@@ -40,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
|
// The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.
|
||||||
// Unexpected token parsing date. Expected String, got StartArray.
|
// Unexpected token parsing date. Expected String, got StartArray.
|
||||||
// Cannot convert null value to System.DateTime.
|
// Cannot convert null value to System.DateTime.
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonConverterAttributeClass
|
public class JsonConverterAttributeClass
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class UserConverter : JsonConverter
|
public class UserConverter : JsonConverter
|
||||||
{
|
{
|
||||||
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
|
||||||
@@ -36,9 +37,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public string UserName { get; set; }
|
public string UserName { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
User user = new User
|
User user = new User
|
||||||
{
|
{
|
||||||
UserName = @"domain\username"
|
UserName = @"domain\username"
|
||||||
@@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(json);
|
Console.WriteLine(json);
|
||||||
// "domain\\username"
|
// "domain\\username"
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonConverterAttributeProperty
|
public class JsonConverterAttributeProperty
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public enum UserStatus
|
public enum UserStatus
|
||||||
{
|
{
|
||||||
NotConfirmed,
|
NotConfirmed,
|
||||||
@@ -22,9 +23,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonConverter(typeof(StringEnumConverter))]
|
[JsonConverter(typeof(StringEnumConverter))]
|
||||||
public UserStatus Status { get; set; }
|
public UserStatus Status { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
User user = new User
|
User user = new User
|
||||||
{
|
{
|
||||||
UserName = @"domain\username",
|
UserName = @"domain\username",
|
||||||
@@ -38,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "UserName": "domain\\username",
|
// "UserName": "domain\\username",
|
||||||
// "Status": "Deleted"
|
// "Status": "Deleted"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonObjectAttributeOptIn
|
public class JsonObjectAttributeOptIn
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
[JsonObject(MemberSerialization.OptIn)]
|
[JsonObject(MemberSerialization.OptIn)]
|
||||||
public class File
|
public class File
|
||||||
{
|
{
|
||||||
@@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty]
|
[JsonProperty]
|
||||||
public int Size { get; set; }
|
public int Size { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
File file = new File
|
File file = new File
|
||||||
{
|
{
|
||||||
Id = Guid.NewGuid(),
|
Id = Guid.NewGuid(),
|
||||||
@@ -36,6 +39,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "ImportantLegalDocuments.docx",
|
// "Name": "ImportantLegalDocuments.docx",
|
||||||
// "Size": 51200
|
// "Size": 51200
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonObjectAttributeOverrideIEnumerable
|
public class JsonObjectAttributeOverrideIEnumerable
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
[JsonObject]
|
[JsonObject]
|
||||||
public class Directory : IEnumerable<string>
|
public class Directory : IEnumerable<string>
|
||||||
{
|
{
|
||||||
@@ -29,9 +30,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
return GetEnumerator();
|
return GetEnumerator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Directory directory = new Directory
|
Directory directory = new Directory
|
||||||
{
|
{
|
||||||
Name = "My Documents",
|
Name = "My Documents",
|
||||||
@@ -52,6 +55,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "WiseFinancalAdvice.xlsx"
|
// "WiseFinancalAdvice.xlsx"
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonPropertyItemLevelSetting
|
public class JsonPropertyItemLevelSetting
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Business
|
public class Business
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -22,9 +23,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty(IsReference = true)]
|
[JsonProperty(IsReference = true)]
|
||||||
public Employee Manager { get; set; }
|
public Employee Manager { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Employee manager = new Employee
|
Employee manager = new Employee
|
||||||
{
|
{
|
||||||
Name = "George-Michael"
|
Name = "George-Michael"
|
||||||
@@ -65,6 +68,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonPropertyName
|
public class JsonPropertyName
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Videogame
|
public class Videogame
|
||||||
{
|
{
|
||||||
[JsonProperty("name")]
|
[JsonProperty("name")]
|
||||||
@@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty("release_date")]
|
[JsonProperty("release_date")]
|
||||||
public DateTime ReleaseDate { get; set; }
|
public DateTime ReleaseDate { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Videogame starcraft = new Videogame
|
Videogame starcraft = new Videogame
|
||||||
{
|
{
|
||||||
Name = "Starcraft",
|
Name = "Starcraft",
|
||||||
@@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "name": "Starcraft",
|
// "name": "Starcraft",
|
||||||
// "release_date": "1998-01-01T00:00:00"
|
// "release_date": "1998-01-01T00:00:00"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonPropertyOrder
|
public class JsonPropertyOrder
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
public string EmailAddress { get; set; }
|
public string EmailAddress { get; set; }
|
||||||
@@ -24,9 +25,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty(Order = -2)]
|
[JsonProperty(Order = -2)]
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Account account = new Account
|
Account account = new Account
|
||||||
{
|
{
|
||||||
FullName = "Aaron Account",
|
FullName = "Aaron Account",
|
||||||
@@ -48,6 +51,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Deleted": true,
|
// "Deleted": true,
|
||||||
// "DeletedDate": "2013-01-25T00:00:00"
|
// "DeletedDate": "2013-01-25T00:00:00"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonPropertyPropertyLevelSetting
|
public class JsonPropertyPropertyLevelSetting
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Vessel
|
public class Vessel
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||||
public DateTime? LaunchDate { get; set; }
|
public DateTime? LaunchDate { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Vessel vessel = new Vessel
|
Vessel vessel = new Vessel
|
||||||
{
|
{
|
||||||
Name = "Red October",
|
Name = "Red October",
|
||||||
@@ -31,6 +34,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "Red October",
|
// "Name": "Red October",
|
||||||
// "Class": "Typhoon"
|
// "Class": "Typhoon"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class JsonPropertyRequired
|
public class JsonPropertyRequired
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Videogame
|
public class Videogame
|
||||||
{
|
{
|
||||||
[JsonProperty(Required = Required.Always)]
|
[JsonProperty(Required = Required.Always)]
|
||||||
@@ -15,12 +16,14 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonProperty(Required = Required.AllowNull)]
|
[JsonProperty(Required = Required.AllowNull)]
|
||||||
public DateTime? ReleaseDate { get; set; }
|
public DateTime? ReleaseDate { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Name"": ""Starcraft III"",
|
'Name': 'Starcraft III',
|
||||||
""ReleaseDate"": null
|
'ReleaseDate': null
|
||||||
}";
|
}";
|
||||||
|
|
||||||
Videogame starcraft = JsonConvert.DeserializeObject<Videogame>(json);
|
Videogame starcraft = JsonConvert.DeserializeObject<Videogame>(json);
|
||||||
@@ -30,6 +33,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(starcraft.ReleaseDate);
|
Console.WriteLine(starcraft.ReleaseDate);
|
||||||
// null
|
// null
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,12 +9,13 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
string json = @"[
|
string json = @"[
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
""1"",
|
'1',
|
||||||
""Two"",
|
'Two',
|
||||||
""III""
|
'III'
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]";
|
]";
|
||||||
@@ -31,6 +32,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
Console.WriteLine(ex.Message);
|
Console.WriteLine(ex.Message);
|
||||||
// The reader's MaxDepth of 2 has been exceeded. Path '[0][0]', line 3, position 12.
|
// The reader's MaxDepth of 2 has been exceeded. Path '[0][0]', line 3, position 12.
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class NullValueHandlingIgnore
|
public class NullValueHandlingIgnore
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Person
|
public class Person
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public Person Partner { get; set; }
|
public Person Partner { get; set; }
|
||||||
public decimal? Salary { get; set; }
|
public decimal? Salary { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Person person = new Person
|
Person person = new Person
|
||||||
{
|
{
|
||||||
Name = "Nigal Newborn",
|
Name = "Nigal Newborn",
|
||||||
@@ -43,6 +46,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "Nigal Newborn",
|
// "Name": "Nigal Newborn",
|
||||||
// "Age": 1
|
// "Age": 1
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class PopulateObject
|
public class PopulateObject
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
public string Email { get; set; }
|
public string Email { get; set; }
|
||||||
@@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public DateTime CreatedDate { get; set; }
|
public DateTime CreatedDate { get; set; }
|
||||||
public IList<string> Roles { get; set; }
|
public IList<string> Roles { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Account account = new Account
|
Account account = new Account
|
||||||
{
|
{
|
||||||
Email = "james@example.com",
|
Email = "james@example.com",
|
||||||
@@ -30,9 +33,9 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
};
|
};
|
||||||
|
|
||||||
string json = @"{
|
string json = @"{
|
||||||
""Active"": false,
|
'Active': false,
|
||||||
""Roles"": [
|
'Roles': [
|
||||||
""Expired""
|
'Expired'
|
||||||
]
|
]
|
||||||
}";
|
}";
|
||||||
|
|
||||||
@@ -46,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(string.Join(", ", account.Roles));
|
Console.WriteLine(string.Join(", ", account.Roles));
|
||||||
// User, Admin, Expired
|
// User, Admin, Expired
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -5,8 +5,9 @@ using System.Text;
|
|||||||
|
|
||||||
namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
||||||
{
|
{
|
||||||
public class ReferenceLoopHandlingObject
|
public class PreserveReferencesHandlingObject
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Directory
|
public class Directory
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -19,9 +20,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public Directory Parent { get; set; }
|
public Directory Parent { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Directory root = new Directory { Name = "Root" };
|
Directory root = new Directory { Name = "Root" };
|
||||||
Directory documents = new Directory { Name = "My Documents", Parent = root };
|
Directory documents = new Directory { Name = "My Documents", Parent = root };
|
||||||
|
|
||||||
@@ -93,6 +96,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class PropertyJsonIgnore
|
public class PropertyJsonIgnore
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
@@ -14,9 +15,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string PasswordHash { get; set; }
|
public string PasswordHash { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Account account = new Account
|
Account account = new Account
|
||||||
{
|
{
|
||||||
FullName = "Joe User",
|
FullName = "Joe User",
|
||||||
@@ -28,6 +31,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(json);
|
Console.WriteLine(json);
|
||||||
// {"FullName":"Joe User","EmailAddress":"joe@example.com"}
|
// {"FullName":"Joe User","EmailAddress":"joe@example.com"}
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -7,14 +7,17 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class ReferenceLoopHandlingIgnore
|
public class ReferenceLoopHandlingIgnore
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Employee
|
public class Employee
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public Employee Manager { get; set; }
|
public Employee Manager { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Employee joe = new Employee { Name = "Joe User" };
|
Employee joe = new Employee { Name = "Joe User" };
|
||||||
Employee mike = new Employee { Name = "Mike Manager" };
|
Employee mike = new Employee { Name = "Mike Manager" };
|
||||||
joe.Manager = mike;
|
joe.Manager = mike;
|
||||||
@@ -32,6 +35,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "Mike Manager"
|
// "Name": "Mike Manager"
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class SerializationCallbackAttributes
|
public class SerializationCallbackAttributes
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class SerializationEventTestObject
|
public class SerializationEventTestObject
|
||||||
{
|
{
|
||||||
// 2222
|
// 2222
|
||||||
@@ -58,9 +59,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
Member4 = "This value was set after deserialization.";
|
Member4 = "This value was set after deserialization.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
SerializationEventTestObject obj = new SerializationEventTestObject();
|
SerializationEventTestObject obj = new SerializationEventTestObject();
|
||||||
|
|
||||||
Console.WriteLine(obj.Member1);
|
Console.WriteLine(obj.Member1);
|
||||||
@@ -98,6 +101,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// This value was set during deserialization
|
// This value was set during deserialization
|
||||||
Console.WriteLine(obj.Member4);
|
Console.WriteLine(obj.Member4);
|
||||||
// This value was set after deserialization.
|
// This value was set after deserialization.
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
List<string> videogames = new List<string>
|
List<string> videogames = new List<string>
|
||||||
{
|
{
|
||||||
"Starcraft",
|
"Starcraft",
|
||||||
@@ -20,6 +21,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(json);
|
Console.WriteLine(json);
|
||||||
// ["Starcraft","Halo","Legend of Zelda"]
|
// ["Starcraft","Halo","Legend of Zelda"]
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+6
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class SerializeConditionalProperty
|
public class SerializeConditionalProperty
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Employee
|
public class Employee
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
@@ -18,9 +19,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
return (Manager != this);
|
return (Manager != this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Employee joe = new Employee();
|
Employee joe = new Employee();
|
||||||
joe.Name = "Joe Employee";
|
joe.Name = "Joe Employee";
|
||||||
Employee mike = new Employee();
|
Employee mike = new Employee();
|
||||||
@@ -33,6 +36,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
mike.Manager = mike;
|
mike.Manager = mike;
|
||||||
|
|
||||||
string json = JsonConvert.SerializeObject(new[] { joe, mike }, Formatting.Indented);
|
string json = JsonConvert.SerializeObject(new[] { joe, mike }, Formatting.Indented);
|
||||||
|
|
||||||
|
Console.WriteLine(json);
|
||||||
// [
|
// [
|
||||||
// {
|
// {
|
||||||
// "Name": "Joe Employee",
|
// "Name": "Joe Employee",
|
||||||
@@ -44,6 +49,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "Name": "Mike Manager"
|
// "Name": "Mike Manager"
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -8,6 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class SerializeContractResolver
|
public class SerializeContractResolver
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Person
|
public class Person
|
||||||
{
|
{
|
||||||
public string FirstName { get; set; }
|
public string FirstName { get; set; }
|
||||||
@@ -18,9 +19,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
get { return FirstName + " " + LastName; }
|
get { return FirstName + " " + LastName; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Person person = new Person
|
Person person = new Person
|
||||||
{
|
{
|
||||||
FirstName = "Sarah",
|
FirstName = "Sarah",
|
||||||
@@ -38,6 +41,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "lastName": "Security",
|
// "lastName": "Security",
|
||||||
// "fullName": "Sarah Security"
|
// "fullName": "Sarah Security"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -11,6 +11,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
DataSet dataSet = new DataSet("dataSet");
|
DataSet dataSet = new DataSet("dataSet");
|
||||||
dataSet.Namespace = "NetFrameWork";
|
dataSet.Namespace = "NetFrameWork";
|
||||||
DataTable table = new DataTable();
|
DataTable table = new DataTable();
|
||||||
@@ -46,6 +47,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
@@ -9,6 +9,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
DateTime mayanEndOfTheWorld = new DateTime(2012, 12, 21);
|
DateTime mayanEndOfTheWorld = new DateTime(2012, 12, 21);
|
||||||
|
|
||||||
string jsonIsoDate = JsonConvert.SerializeObject(mayanEndOfTheWorld);
|
string jsonIsoDate = JsonConvert.SerializeObject(mayanEndOfTheWorld);
|
||||||
@@ -23,6 +24,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
|
|
||||||
Console.WriteLine(jsonMsDate);
|
Console.WriteLine(jsonMsDate);
|
||||||
// "\/Date(1356044400000+0100)\/"
|
// "\/Date(1356044400000+0100)\/"
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-1
@@ -7,6 +7,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
{
|
{
|
||||||
public class SerializeDateTimeZoneHandling
|
public class SerializeDateTimeZoneHandling
|
||||||
{
|
{
|
||||||
|
#region Types
|
||||||
public class Flight
|
public class Flight
|
||||||
{
|
{
|
||||||
public string Destination { get; set; }
|
public string Destination { get; set; }
|
||||||
@@ -15,9 +16,11 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
public DateTime DepartureDateLocal { get; set; }
|
public DateTime DepartureDateLocal { get; set; }
|
||||||
public TimeSpan Duration { get; set; }
|
public TimeSpan Duration { get; set; }
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void Example()
|
public void Example()
|
||||||
{
|
{
|
||||||
|
#region Usage
|
||||||
Flight flight = new Flight
|
Flight flight = new Flight
|
||||||
{
|
{
|
||||||
Destination = "Dubai",
|
Destination = "Dubai",
|
||||||
@@ -82,6 +85,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Examples.Serializer
|
|||||||
// "DepartureDateLocal": "2013-01-21T00:00:00",
|
// "DepartureDateLocal": "2013-01-21T00:00:00",
|
||||||
// "Duration": "05:30:00"
|
// "Duration": "05:30:00"
|
||||||
// }
|
// }
|
||||||
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user