ChrisCompleteCodeTrunk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
<?xml version="1.0" encoding="utf-8"?>
<topic id="ContractResolver" revisionNumber="1">
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
<!--
<summary>
<para>Optional summary abstract</para>
</summary>
-->
<introduction>
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
interface provides a way to customize how the
JsonSerializer serializes and deserializes .NET objects to JSON without placing attributes on your classes.
</para>
<para>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 overridden.</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 <link xlink:href="ConditionalProperties">conditional serialization for a property</link> 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>
|
Revision |
Author |
Commited |
Message |
1
|
BBDSCHRIS
|
Wed 22 Aug, 2018 20:08:03 +0000 |
|