You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Uncomment this to generate an outline of the section and sub-section
11
-
titles. Specify a numeric value as the inner text to limit it to
12
-
a specific number of sub-topics when creating the outline. Specify
13
-
zero (0) to limit it to top-level sections only. -->
14
-
<!-- <autoOutline /> -->
15
6
<para>Attributes can be used to control how Json.NET serializes and deserializes .NET objects.</para>
16
-
7
+
17
8
<listclass="bullet">
18
9
<listItem><para><codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference> - Placed on classes to control how they should be serialized as a JSON object.</para></listItem>
19
10
<listItem><para><codeEntityReference>T:Newtonsoft.Json.JsonArrayAttribute</codeEntityReference> - Placed on collections to control how they should be serialized as a JSON array.</para></listItem>
<!-- Uncomment this to create a sub-section outline
32
-
<autoOutline /> -->
33
22
<para>As well as using the built-in Json.NET attributes, Json.NET also looks for the <codeEntityReference>T:System.SerializableAttribute</codeEntityReference>
34
23
(if IgnoreSerializableAttribute on DefaultContractResolver is set to false)
and <codeEntityReference>T:System.NonSerializedAttribute</codeEntityReference> and attributes when determining how JSON is to be serialized and deserialized.
38
27
</para>
39
28
40
-
41
29
<alertclass="note">
42
30
<para>Json.NET attributes take precedence over standard .NET serialization attributes (e.g. if both JsonPropertyAttribute
43
31
and DataMemberAttribute are present on a property and both customize the name,
@@ -55,8 +43,6 @@
55
43
<section>
56
44
<title>JsonObjectAttribute</title>
57
45
<content>
58
-
<!-- Uncomment this to create a sub-section outline
59
-
<autoOutline /> -->
60
46
<para>The MemberSerialization flag on this attribute specifies whether member serialization is opt-in
61
47
(a member must have the JsonProperty or DataMember attribute to be serialized), opt-out (everything is
62
48
serialized by default but can be ignored with the JsonIgnoreAttribute, Json.NET's default behavior) or
<!-- Uncomment this to create a sub-section outline
76
-
<autoOutline /> -->
77
61
<para>The JsonArrayAttribute and JsonDictionaryAttributes are used to specify whether a class is serialized as that collection type.</para>
78
62
<para>The collection attributes have options to customize the JsonConverter, type name handling, and reference handling that are applied to collection items.</para>
79
63
</content>
@@ -82,8 +66,6 @@
82
66
<section>
83
67
<title>JsonPropertyAttribute</title>
84
68
<content>
85
-
<!-- Uncomment this to create a sub-section outline
86
-
<autoOutline /> -->
87
69
<para>JsonPropertyAttribute has a number of uses:</para>
88
70
89
71
<listclass="bullet">
@@ -110,9 +92,8 @@
110
92
<section>
111
93
<title>JsonConverterAttribute</title>
112
94
<content>
113
-
<!-- Uncomment this to create a sub-section outline
114
-
<autoOutline /> -->
115
-
<para>The JsonConverterAttribute specifies which JsonSerializer is used to convert an object.</para>
95
+
<para>The <codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference> specifies which
96
+
<codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> is used to convert an object.</para>
116
97
<para>The attribute can be placed on a class or a member. When placed on a class, the JsonConverter
117
98
specified by the attribute will be the default way of serializing that class. When the attribute is
118
99
on a field or property, then the specified JsonConverter will always be used to serialize that value.</para>
@@ -135,8 +116,10 @@
135
116
<section>
136
117
<title>JsonExtensionDataAttribute</title>
137
118
<content>
138
-
<para>Instructs the <codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference> to deserialize properties with no matching class member
139
-
into the specified collection and write values during serialization.</para>
119
+
<para>The <codeEntityReference>T:Newtonsoft.Json.JsonExtensionDataAttribute</codeEntityReference> instructs the
120
+
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference> to deserialize properties with no matching field or property
121
+
on the type into the specified collection. During serialization the values in this collection are written back to the instance's JSON object.</para>
122
+
<para>This example shows the JsonExtensionDataAttribute being applied to a field, unmatched JSON properties being added to the field's collection during deserialization.</para>
0 commit comments