71 lines
3.6 KiB
XML
71 lines
3.6 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<topic id="ContractResolver" revisionNumber="1">
|
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<!--
|
|
<summary>
|
|
<para>Optional summary abstract</para>
|
|
</summary>
|
|
-->
|
|
<introduction>
|
|
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
|
interface provides a way to customize how the
|
|
JsonSerializer serializes and deserializes .NET objects to JSON.</para>
|
|
<para>Implementing the IContractResolver interface and then assigning an
|
|
instance to a JsonSerializer lets you control whether the object is
|
|
serialized as a JSON object or JSON array, what object members should be
|
|
serialized, how they are serialized and what they are called.</para>
|
|
</introduction>
|
|
<!-- Add one or more top-level section elements. These are collapsible.
|
|
If using <autoOutline />, add an address attribute to identify it
|
|
and specify a title so that it can be jumped to with a hyperlink. -->
|
|
<section>
|
|
<title>DefaultContractResolver</title>
|
|
<content>
|
|
<!-- Uncomment this to create a sub-section outline
|
|
<autoOutline /> -->
|
|
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
|
is the default resolver used by the
|
|
serializer. It provides many avenues of extensibility in the form of
|
|
virtual methods that can be overriden.</para>
|
|
</content>
|
|
</section>
|
|
<section>
|
|
<title>CamelCasePropertyNamesContractResolver</title>
|
|
<content>
|
|
<!-- Uncomment this to create a sub-section outline
|
|
<autoOutline /> -->
|
|
<para><codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
|
inherits from DefaultContractResolver and simply overrides the JSON
|
|
property name to be written in <externalLink>
|
|
<linkText>camelcase</linkText>
|
|
<linkUri>http://en.wikipedia.org/wiki/CamelCase</linkUri>
|
|
<linkTarget>_blank</linkTarget>
|
|
</externalLink>.</para>
|
|
|
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ContractResolver" title="ContractResolver" />
|
|
</content>
|
|
</section>
|
|
<section>
|
|
<title>Custom Examples</title>
|
|
<content>
|
|
<para>Setting a <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> on a type
|
|
using an IContractResolver.</para>
|
|
|
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\PerformanceTests.cs" region="JsonConverterContractResolver" title="Use JsonConverter with IContractResolver" />
|
|
|
|
<para><externalLink>
|
|
<linkText>Conditionally serializing properties</linkText>
|
|
<linkUri>ConditionalProperties.htm</linkUri>
|
|
<linkTarget>_self</linkTarget>
|
|
</externalLink> using an IContractResolver.</para>
|
|
|
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConditionalPropertiesTests.cs" region="ShouldSerializeContractResolver" title="Conditional properties with IContractResolver" />
|
|
</content>
|
|
</section>
|
|
<relatedTopics>
|
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
|
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
|
|
<codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
|
|
</relatedTopics>
|
|
</developerConceptualDocument>
|
|
</topic> |