-Line endings
This commit is contained in:
@@ -1,30 +1,30 @@
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Serializing Collections</title>
|
||||
<link href="styles.css" rel="stylesheet" type="text/css" />
|
||||
<link href="custom.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="control">
|
||||
<span class="productTitle">Json.NET - Quick Starts & API Documentation</span><br />
|
||||
<span class="topicTitle">Serializing Collections</span></div>
|
||||
|
||||
<div id="content">
|
||||
<span style="color: DarkGray"> </span>
|
||||
|
||||
<p>The <a href="./html/T_Newtonsoft_Json_JsonSerializer.htm">JsonSerializer</a> has
|
||||
great support for serializing and deserializing collections of objects.</p>
|
||||
|
||||
<h3>Serializing</h3>
|
||||
<p>To serialize a collection - a generic list, array, dictionary, or your own custom collection - simply call the serializer with the object you want to get JSON for.
|
||||
Json.NET will serialize the collection and all of the values it contains.</p>
|
||||
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<title>Serializing Collections</title>
|
||||
<link href="styles.css" rel="stylesheet" type="text/css" />
|
||||
<link href="custom.css" rel="stylesheet" type="text/css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<div id="control">
|
||||
<span class="productTitle">Json.NET - Quick Starts & API Documentation</span><br />
|
||||
<span class="topicTitle">Serializing Collections</span></div>
|
||||
|
||||
<div id="content">
|
||||
<span style="color: DarkGray"> </span>
|
||||
|
||||
<p>The <a href="./html/T_Newtonsoft_Json_JsonSerializer.htm">JsonSerializer</a> has
|
||||
great support for serializing and deserializing collections of objects.</p>
|
||||
|
||||
<h3>Serializing</h3>
|
||||
<p>To serialize a collection - a generic list, array, dictionary, or your own custom collection - simply call the serializer with the object you want to get JSON for.
|
||||
Json.NET will serialize the collection and all of the values it contains.</p>
|
||||
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
<div style="font-family: Courier New; font-size: 10pt; color: black;">
|
||||
<pre style="margin: 0px;"><span style="color: #2b91af;">Product</span> p1 = <span style="color: blue;">new</span> <span style="color: #2b91af;">Product</span></pre>
|
||||
<pre style="margin: 0px;"> {</pre>
|
||||
@@ -59,14 +59,14 @@
|
||||
<pre style="margin: 0px;"><span style="color: green;">// }</span></pre>
|
||||
<pre style="margin: 0px;"><span style="color: green;">//]</span></pre>
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
|
||||
<h3>Deserializing</h3>
|
||||
<p>To deserialize JSON into a .NET collection just specify the collection type you want to deserialize to. Json.NET supports a wide range of collection types.</p>
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
|
||||
</div></div>
|
||||
|
||||
<h3>Deserializing</h3>
|
||||
<p>To deserialize JSON into a .NET collection just specify the collection type you want to deserialize to. Json.NET supports a wide range of collection types.</p>
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
<div style="font-family: Courier New; font-size: 10pt; color: black;">
|
||||
<pre style="margin: 0px;"><span style="color: blue;">string</span> json = <span style="color: #a31515;">@"[</span></pre>
|
||||
<pre style="margin: 0px;"><span style="color: #a31515;"> {</span></pre>
|
||||
@@ -93,15 +93,15 @@
|
||||
<pre style="margin: 0px;"><span style="color: #2b91af;">Console</span>.WriteLine(p1.Name);</pre>
|
||||
<pre style="margin: 0px;"><span style="color: green;">// Product 1</span></pre>
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
|
||||
<h3>Deserializing Dictionaries</h3>
|
||||
|
||||
<p>Using Json.NET you can also deserialize a JSON object into a .NET generic dictionary. The JSON object's property names and values will be added to the dictionary.</p>
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
|
||||
</div></div>
|
||||
|
||||
<h3>Deserializing Dictionaries</h3>
|
||||
|
||||
<p>Using Json.NET you can also deserialize a JSON object into a .NET generic dictionary. The JSON object's property names and values will be added to the dictionary.</p>
|
||||
|
||||
<div class="overflowpanel"> <div class="code">
|
||||
|
||||
<div style="font-family: Courier New; font-size: 10pt; color: black;">
|
||||
<pre style="margin: 0px;"><span style="color: blue;">string</span> json = <span style="color: #a31515;">@"{""key1"":""value1"",""key2"":""value2""}"</span>;</pre>
|
||||
<pre style="margin: 0px;"> </pre>
|
||||
@@ -113,16 +113,16 @@
|
||||
<pre style="margin: 0px;"><span style="color: #2b91af;">Console</span>.WriteLine(values[<span style="color: #a31515;">"key1"</span>]);</pre>
|
||||
<pre style="margin: 0px;"><span style="color: green;">// value1</span></pre>
|
||||
</div>
|
||||
|
||||
</div></div>
|
||||
|
||||
<div id="footer">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
</div></div>
|
||||
|
||||
<div id="footer">
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user