1
<?xml version="1.0" encoding="utf-8"?>
2
<topic id="SerializingJSON" revisionNumber="1">
3
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
6
<para>Optional summary abstract</para>
10
<para>The quickest method of converting between JSON text and a .NET object is using the
11
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>.
12
The JsonSerializer converts .NET objects into their JSON equivalent and back again by mapping the .NET object property names to the JSON property names
13
and copies the values for you.</para>
15
<!-- Optional procedures followed by optional code example but must have
16
at least one procedure or code example -->
18
<title>JsonConvert</title>
19
<content><para>For simple scenarios where you want to convert to and from a JSON string the
20
<codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.SerializeObject</codeEntityReference> and
21
<codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.DeserializeObject</codeEntityReference>
22
methods on JsonConvert provide an easy to use wrapper over JsonSerializer.</para>
23
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializeObject" title="Serializing and Deserializing JSON with JsonConvert" />
25
SerializeObject and DeserializeObject both have overloads that take a <codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference> object.
26
JsonSerializerSettings lets you use many of the JsonSerializer settings listed below while still using the simple serialization methods.
32
<title>JsonSerializer</title>
33
<content><para>For more control over how an object is serialized the <codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference> can be used directly.
34
The JsonSerializer is able to read and write JSON text directly to a stream via <codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference>
35
and <codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference>.
36
Other kinds of JsonWriters can also be used such as
37
<codeEntityReference>T:Newtonsoft.Json.Linq.JTokenReader</codeEntityReference>/<codeEntityReference>T:Newtonsoft.Json.Linq.JTokenWriter</codeEntityReference>
38
to convert your object to and from
39
LINQ to JSON objects or
40
<codeEntityReference>T:Newtonsoft.Json.Bson.BsonReader</codeEntityReference>/<codeEntityReference>T:Newtonsoft.Json.Bson.BsonWriter</codeEntityReference> to convert to and from BSON.</para>
42
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="JsonSerializerToStream" title="Serializing JSON to a Stream with JsonSerializer" />
44
<para>JsonSerializer has a number of properties on it to customize how it serializes JSON. These can also be used with the methods on JsonConvert via the JsonSerializerSettings overloads.</para>
45
<para>Read more about the available JsonSerializer settings here: <externalLink>
46
<linkText>Serialization Settings</linkText>
47
<linkUri>SerializationSettings.htm</linkUri>
48
<linkTarget>_self</linkTarget>
49
</externalLink></para>
54
<linkText>Serialization Guide</linkText>
55
<linkUri>SerializationGuide.htm</linkUri>
56
<linkTarget>_self</linkTarget>
59
<linkText>Serialization Settings</linkText>
60
<linkUri>SerializationSettings.htm</linkUri>
61
<linkTarget>_self</linkTarget>
64
<linkText>Serialization Attributes</linkText>
65
<linkUri>SerializationAttributes.htm</linkUri>
66
<linkTarget>_self</linkTarget>
69
<linkText>Serializing Partial JSON Fragments</linkText>
70
<linkUri>SerializingJSONFragments.htm</linkUri>
71
<linkTarget>_self</linkTarget>
74
<codeEntityReference>T:Newtonsoft.Json.JsonConvert</codeEntityReference>
75
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
76
<codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference>
78
</developerConceptualDocument>
b'\\ No newline at end of file'