Skip to content
Browse files

-Fixes to XML documentation

-Sandcastle Help File Builder project added
-Quickstart guides added
  • Loading branch information...
1 parent 3209f09 commit d88e2cf2ca2579b36e45e128ec2fbb3570199169 @JamesNK JamesNK committed
View
193 Src/Doc/LINQtoJSON.html
@@ -0,0 +1,193 @@
+<html>
+
+ <head>
+ <title>Reading and Writing JSON</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">Reading and Writing JSON</span></div>
+
+ <div id="content">
+ <span style="color: DarkGray"> </span>
+
+ <p>LINQ to JSON is a programming API for working with JSON objects. The API has been designed with LINQ in mind to enable to quick querying and creation of JSON objects. LINQ to JSON sits under the <a href="./html/N_Newtonsoft_Json_Linq.htm">Newtonsoft.Json.Linq</a> namespace.</p>
+
+<h3>Creating JSON</h3>
+<p>There are a number of different options when it comes to creating JSON using LINQ to JSON. The first to create objects imperatively. You have total control but it is more verbose than other options.</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;">JArray</span> array = <span style="color: blue;">new</span> <span style="color: #2b91af;">JArray</span>();</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JValue</span> text = <span style="color: blue;">new</span> <span style="color: #2b91af;">JValue</span>(<span style="color: #a31515;">"Manual text"</span>);</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JValue</span> date = <span style="color: blue;">new</span> <span style="color: #2b91af;">JValue</span>(<span style="color: blue;">new</span> <span style="color: #2b91af;">DateTime</span>(2000, 5, 23));</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;">array.Add(text);</pre>
+<pre style="margin: 0px;">array.Add(date);</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">string</span> json = array.ToString();</pre>
+<pre style="margin: 0px;"><span style="color: green;">// [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Manual text",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "\/Date(958996800000+1200)\/"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">// ]</span></pre>
+</div>
+
+</div></div>
+
+<p>Another option is to create JSON objects declaratively.</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;">List</span>&lt;<span style="color: #2b91af;">Post</span>&gt; posts = GetPosts();</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JObject</span> rss =</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JObject</span>(</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"channel"</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JObject</span>(</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"title"</span>, <span style="color: #a31515;">"James Newton-King"</span>),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"link"</span>, <span style="color: #a31515;">"http://james.newtonking.com"</span>),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"description"</span>, <span style="color: #a31515;">"James Newton-King's blog."</span>),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"item"</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JArray</span>(</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">from</span> p <span style="color: blue;">in</span> posts</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">orderby</span> p.Title</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">select</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">JObject</span>(</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"title"</span>, p.Title),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"description"</span>, p.Description),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"link"</span>, p.Link),</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"category"</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JArray</span>(</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">from</span> c <span style="color: blue;">in</span> p.Categories</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">select</span> <span style="color: blue;">new</span> <span style="color: #2b91af;">JValue</span>(c)))))))));</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">Console</span>.WriteLine(rss.ToString());</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: green;">//{</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "channel": {</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "title": "James Newton-King",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "link": "http://james.newtonking.com",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "description": "James Newton-King's blog.",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "item": [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; {</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "title": "Json.NET 1.3 + New license + Now on CodePlex",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "description": "Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "link": "http://james.newtonking.com/projects/json-net.aspx",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "category": [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Json.NET",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "CodePlex"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; },</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; {</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "title": "LINQ to JSON beta",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "description": "Annoucing LINQ to JSON",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "link": "http://james.newtonking.com/projects/json-net.aspx",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; "category": [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "Json.NET",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "LINQ"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; &nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; &nbsp; }</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; }</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//}</span></pre>
+</div>
+
+</div></div>
+
+<p>You can create a JSON object from a non-JSON type using the <a href="./html/M_Newtonsoft_Json_Linq_JObject_FromObject.htm">FromObject</a> method.</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;">JObject</span> o = <span style="color: #2b91af;">JObject</span>.FromObject(<span style="color: blue;">new</span></pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; channel = <span style="color: blue;">new</span></pre>
+<pre style="margin: 0px;">&nbsp; {</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; title = <span style="color: #a31515;">"James Newton-King"</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; link = <span style="color: #a31515;">"http://james.newtonking.com"</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; description = <span style="color: #a31515;">"James Newton-King's blog."</span>,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; item =</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">from</span> p <span style="color: blue;">in</span> posts</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">orderby</span> p.Title</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: blue;">select</span> <span style="color: blue;">new</span></pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; {</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; title = p.Title,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; description = p.Description,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; link = p.Link,</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; category = p.Categories</pre>
+<pre style="margin: 0px;">&nbsp; &nbsp; &nbsp; &nbsp; }</pre>
+<pre style="margin: 0px;">&nbsp; }</pre>
+<pre style="margin: 0px;">});</pre>
+</div>
+
+</div></div>
+
+<p>Finally JSON objects can be created from a string use the <a href="./html/M_Newtonsoft_Json_Linq_JObject_Parse.htm">Parse</a> method.</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;">&nbsp; CPU: 'Intel',</span></pre>
+<pre style="margin: 0px;"><span style="color: #a31515;">&nbsp; Drives: [</span></pre>
+<pre style="margin: 0px;"><span style="color: #a31515;">&nbsp; &nbsp; 'DVD read/writer',</span></pre>
+<pre style="margin: 0px;"><span style="color: #a31515;">&nbsp; &nbsp; ""500 gigabyte hard drive""</span></pre>
+<pre style="margin: 0px;"><span style="color: #a31515;">&nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: #a31515;">}"</span>;</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JObject</span> o = <span style="color: #2b91af;">JObject</span>.Parse(json);</pre>
+</div>
+
+</div></div>
+
+ <h3>Querying JSON</h3>
+
+
+ <p>The properties methods that are the most useful when querying JSON objects are <a href="./html/Overload_Newtonsoft_Json_Linq_JToken_Children.htm">Children</a>, <a href="./html/M_Newtonsoft_Json_Linq_JToken_Values__1.htm">Values</a> and the <a href="./html/P_Newtonsoft_Json_Linq_JToken_Item.htm">property index</a>.</p>
+ <p>Children returns all the children of that object. Values is similar to Children but it allows you to specify a type you would like the values to be converted into. Finally the property index is used to get a specific child, either by index position for JSON arrays or property name for JSON objects.</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;">var</span> postTitles =</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">from</span> p <span style="color: blue;">in</span> rss[<span style="color: #a31515;">"channel"</span>][<span style="color: #a31515;">"item"</span>].Children()</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">select</span> p.Value&lt;<span style="color: blue;">string</span>&gt;(<span style="color: #a31515;">"title"</span>);</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> item <span style="color: blue;">in</span> postTitles)</pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: #2b91af;">Console</span>.WriteLine(item);</pre>
+<pre style="margin: 0px;">}</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: green;">//LINQ to JSON beta</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//Json.NET 1.3 + New license + Now on CodePlex</span></pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">var</span> categories =</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">from</span> c <span style="color: blue;">in</span> rss[<span style="color: #a31515;">"channel"</span>][<span style="color: #a31515;">"item"</span>].Children()[<span style="color: #a31515;">"category"</span>].Values&lt;<span style="color: blue;">string</span>&gt;()</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">group</span> c <span style="color: blue;">by</span> c <span style="color: blue;">into</span> g</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">orderby</span> g.Count() <span style="color: blue;">descending</span></pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">select</span> <span style="color: blue;">new</span> { Category = g.Key, Count = g.Count() };</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">foreach</span> (<span style="color: blue;">var</span> c <span style="color: blue;">in</span> categories)</pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: #2b91af;">Console</span>.WriteLine(c.Category + <span style="color: #a31515;">" - Count: "</span> + c.Count);</pre>
+<pre style="margin: 0px;">}</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: green;">//Json.NET - Count: 2</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//LINQ - Count: 1</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//CodePlex - Count: 1</span></pre>
+</div>
+
+</div></div>
+
+ <div id="footer"></div>
+ </div>
+
+ </body>
+
+</html>
View
87 Src/Doc/ReadingWritingJSON.html
@@ -0,0 +1,87 @@
+<html>
+
+ <head>
+ <title>LINQ to JSON</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">LINQ to JSON</span></div>
+
+ <div id="content">
+ <span style="color: DarkGray"> </span>
+
+ <p>To manually read and write JSON Json.NET provides the <a href="./html/T_Newtonsoft_Json_JsonReader.htm>JsonReader</a> and <a href="./html/T_Newtonsoft_Json_JsonWriter.htm">JsonWriter</a> classes.</p>
+
+<h3>JsonTextReader and JsonTextWriter</h3>
+<p><a href="./html/T_Newtonsoft_Json_JsonTextReader.htm">JsonTextReader</a> and <a href="./html/T_Newtonsoft_Json_JsonTextWriter.htm">JsonTextWriter</a> are used to read and write JSON text. The JsonTextWriter has a number of settings on it to control how JSON is formatted when it is written. These options include formatting, indention character, indent count and quote character.</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;">StringBuilder</span> sb = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">StringWriter</span> sw = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringWriter</span>(sb);</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">JsonWriter</span> jsonWriter = <span style="color: blue;">new</span> <span style="color: #2b91af;">JsonTextWriter</span>(sw))</pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.Formatting = <span style="color: #2b91af;">Formatting</span>.Indented;</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteStartObject();</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WritePropertyName(<span style="color: #a31515;">"CPU"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteValue(<span style="color: #a31515;">"Intel"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WritePropertyName(<span style="color: #a31515;">"PSU"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteValue(<span style="color: #a31515;">"500W"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WritePropertyName(<span style="color: #a31515;">"Drives"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteStartArray();</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteValue(<span style="color: #a31515;">"DVD read/writer"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteComment(<span style="color: #a31515;">"(broken)"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteValue(<span style="color: #a31515;">"500 gigabyte hard drive"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteValue(<span style="color: #a31515;">"200 gigabype hard drive"</span>);</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteEnd();</pre>
+<pre style="margin: 0px;">&nbsp; jsonWriter.WriteEndObject();</pre>
+<pre style="margin: 0px;">}</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: green;">// {</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "CPU": "Intel",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "PSU": "500W",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Drives": [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "DVD read/writer"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; /*(broken)*/,</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "500 gigabyte hard drive",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "200 gigabype hard drive"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">// }</span></pre>
+</div>
+
+</div></div>
+
+<h3>JsonTokenReader and JsonTokenWriter</h3>
+<p><a href="./html/T_Newtonsoft_Json_JsonTokenReader.htm">JsonTokenReader</a> and <a href="./html/T_Newtonsoft_Json_JsonTokenWriter.htm">JsonTokenWriter</a> read and write LINQ to JSON objects. They are located in the <a href="./html/N_Newtonsoft_Json_Linq.htm">Newtonsoft.Json.Linq</a> namespace. These objects allow you to use LINQ to JSON objects with objects that read and write JSON such as the JsonSerializer. For example you can deserialize from a LINQ to JSON object into a regular .NET object and vice versa.</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;">JObject</span> o = <span style="color: blue;">new</span> <span style="color: #2b91af;">JObject</span>(</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"Name"</span>, <span style="color: #a31515;">"John Smith"</span>),</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">new</span> <span style="color: #2b91af;">JProperty</span>(<span style="color: #a31515;">"BirthDate"</span>, <span style="color: blue;">new</span> <span style="color: #2b91af;">DateTime</span>(1983, 3, 20))</pre>
+<pre style="margin: 0px;">&nbsp; );</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JsonSerializer</span> serializer = <span style="color: blue;">new</span> <span style="color: #2b91af;">JsonSerializer</span>();</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">Person</span> p = (<span style="color: #2b91af;">Person</span>)serializer.Deserialize(<span style="color: blue;">new</span> <span style="color: #2b91af;">JsonTokenReader</span>(o), <span style="color: blue;">typeof</span>(<span style="color: #2b91af;">Person</span>));</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: green;">// John Smith</span></pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">Console</span>.WriteLine(p.Name);</pre>
+</div>
+
+</div></div>
+
+ <div id="footer"></div>
+ </div>
+
+ </body>
+
+</html>
View
144 Src/Doc/SerializingJSON.html
@@ -0,0 +1,144 @@
+<html>
+
+ <head>
+ <title>Serializing and deserializing JSON</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 and deserializing JSON</span></div>
+
+ <div id="content">
+ <span style="color: DarkGray"> </span>
+
+ <p>The quickest method of converting between JSON text and a .NET object is using
+ the <a href="./html/T_Newtonsoft_Json_JsonSerializer.htm">JsonSerializer</a>. The JsonSerializer converts .NET objects into their JSON
+ equivalent and back again.</p>
+
+
+ <p>For simple scenarios the <a href="./html/Overload_Newtonsoft_Json_JavaScriptConvert_SerializeObject.htm">SerializeObject</a> and <a href="./html/Overload_Newtonsoft_Json_JavaScriptConvert_DeserializeObject.htm">DeserializeObject</a> methods on <a href="./html/T_Newtonsoft_Json_JavaScriptConvert.htm">JavaScriptConvert</a> provide an easy to use wrapper over
+ JsonSerializer.</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> product = <span style="color: blue;">new</span> <span style="color: #2b91af;">Product</span>();</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;">product.Name = <span style="color: #a31515;">"Apple"</span>;</pre>
+<pre style="margin: 0px;">product.Expiry = <span style="color: blue;">new</span> <span style="color: #2b91af;">DateTime</span>(2008, 12, 28);</pre>
+<pre style="margin: 0px;">product.Price = 3.99M;</pre>
+<pre style="margin: 0px;">product.Sizes = <span style="color: blue;">new</span> <span style="color: blue;">string</span>[] { <span style="color: #a31515;">"Small"</span>, <span style="color: #a31515;">"Medium"</span>, <span style="color: #a31515;">"Large"</span> };</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">string</span> output = <span style="color: #2b91af;">JavaScriptConvert</span>.SerializeObject(product);</pre>
+<pre style="margin: 0px;"><span style="color: green;">//{</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Name": "Apple",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Expiry": &quot;\/Date(1230375600000+1300)\/&quot;,</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Price": 3.99,</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; "Sizes": [</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "Small",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "Medium",</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; &nbsp; "Large"</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//&nbsp; ]</span></pre>
+<pre style="margin: 0px;"><span style="color: green;">//}</span></pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">Product</span> deserializedProduct = (<span style="color: #2b91af;">Product</span>)<span style="color: #2b91af;">JavaScriptConvert</span>.DeserializeObject(output, <span style="color: blue;">typeof</span>(<span style="color: #2b91af;">Product</span>));</pre>
+</div>
+
+</div></div>
+
+ <h3>JsonSerializer</h3>
+
+
+ <p>For more control over how an object is serialized the JsonSerializer can be used
+ directly. The JsonSerializer has a number of properties to control its behaviour
+ when serializing and deserializing.</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> product = <span style="color: blue;">new</span> <span style="color: #2b91af;">Product</span>();</pre>
+<pre style="margin: 0px;">product.Expiry = <span style="color: blue;">new</span> <span style="color: #2b91af;">DateTime</span>(2008, 12, 28);</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: #2b91af;">JsonSerializer</span> serializer = <span style="color: blue;">new</span> <span style="color: #2b91af;">JsonSerializer</span>();</pre>
+<pre style="margin: 0px;">serializer.Converters.Add(<span style="color: blue;">new</span> <span style="color: #2b91af;">JavaScriptDateTimeConverter</span>());</pre>
+<pre style="margin: 0px;">serializer.NullValueHandling = <span style="color: #2b91af;">NullValueHandling</span>.Ignore;</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">StreamWriter</span> sw = <span style="color: blue;">new</span> <span style="color: #2b91af;">StreamWriter</span>(<span style="color: #a31515;">@"c:\json.txt"</span>))</pre>
+<pre style="margin: 0px;"><span style="color: blue;">using</span> (<span style="color: #2b91af;">JsonWriter</span> writer = <span style="color: blue;">new</span> <span style="color: #2b91af;">JsonTextWriter</span>(sw))</pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; serializer.Serialize(writer, product);</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: green;">// {"Expiry":new Date(1230375600000),"Price":0}</span></pre>
+<pre style="margin: 0px;">}</pre>
+</div>
+
+</div></div>
+
+<h5>ReferenceLoopHandling</h5>
+<p>Controls how circular referencing objects are serialized. Error, ignore or
+ serialize.</p>
+ <h5>MissingMemberHandling</h5>
+<p>Controls how missing members (e.g. JSON contains a property that isn&#39;t a member
+ on the object) are handled during deserialization. Error or ignore.</p>
+ <h5>NullValueHandling</h5>
+<p>Controls how null values are handled during serialization and deserialization.
+ Include or ignore.</p>
+ <h5>ObjectCreationHandling</h5>
+<p>Controls how objects are created during deserialization. Auto, reuse, replace.</p>
+ <h5>Converters</h5>
+<p>A collection of JsonConverters that will be used during serialization and
+ deserialization.</p>
+ <h3>Serialization Attributes</h3>
+ <p>There are a number of optional attributes that can be placed on a class to control how it is serialized.</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;">JsonObject</span>(<span style="color: #2b91af;">MemberSerialization</span>.OptIn)]</pre>
+<pre style="margin: 0px;"><span style="color: blue;">public</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Person</span></pre>
+<pre style="margin: 0px;">{</pre>
+<pre style="margin: 0px;">&nbsp; [<span style="color: #2b91af;">JsonProperty</span>]</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">string</span> Name { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;">&nbsp; [<span style="color: #2b91af;">JsonProperty</span>]</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">public</span> <span style="color: #2b91af;">DateTime</span> BirthDate { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre>
+<pre style="margin: 0px;">&nbsp;</pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: green;">// not serialized</span></pre>
+<pre style="margin: 0px;">&nbsp; <span style="color: blue;">public</span> <span style="color: blue;">string</span> Department { <span style="color: blue;">get</span>; <span style="color: blue;">set</span>; }</pre>
+<pre style="margin: 0px;">}</pre>
+</div>
+
+</div></div>
+
+ <h5>JsonObjectAttribute</h5>
+<p>The MemberSerialization flag on this attribute specifies whether member serialization is opt-in (a member must have the JsonPropertyAttribute to be serialized) or opt-out (everything is serialized by default but can be ignored with the JsonIgnoreAttribute).</p>
+ <h5>JsonPropertyAttribute</h5>
+<p>Allows the name of the serialized member to be customized. The attribute also indicates that a member should be serialized when member serialization is set to opt-in.</p>
+ <h5>JsonIgnoreAttribute</h5>
+<p>Excludes a field or property from serialization.</p>
+ <h3>JsonConverters</h3>
+<p>JsonConverters allows JSON to be manually be written during serialization and read during deserialization. This is useful for particularly complex JSON structures or for when you want to change how a type is serialized.</p>
+<p>To create your own custom converter inherit from the JsonConverter class. Json.NET also comes with a number of JsonConverters:</p>
+
+
+
+ <h5>IsoDateTimeConverter</h5>
+ <p>Converts a DateTime to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).</p>
+
+ <h5>JavaScriptDateTimeConverter</h5>
+ <p>Converts a DateTime to and from a JavaScript date constructor (e.g. new Date(52231943)).</p>
+
+ <h5>XmlNodeConverter</h5>
+ <p>Converts an XmlNode to and from JSON. Note that to convert a JSON object it must have only a single property. This is required because properties are converted into nodes and XML can only have one root node.</p>
+
+
+ <div id="footer"></div>
+ </div>
+
+ </body>
+
+</html>
View
19 Src/Doc/custom.css
@@ -0,0 +1,19 @@
+div#content {
+ padding: 0 10px 10px 10px;
+}
+
+.overflowpanel
+{
+ width: 98%;
+ border: solid 1px #ccc;
+ overflow: auto;
+ overflow-y: hidden;
+ background-color: #fcfcfc;
+ margin-bottom: 1em;
+}
+
+.overflowpanel .code
+{
+ padding: 10px 4px 20px 10px;
+ display: block;
+}
View
56 Src/Doc/doc.shfb
@@ -0,0 +1,56 @@
+<project schemaVersion="1.6.0.2">
+ <assemblies>
+ <assembly assemblyPath="D:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\bin\Release\Newtonsoft.Json.dll" xmlCommentsPath="D:\Newtonsoft\Projects\Json\trunk\Src\Newtonsoft.Json\bin\Release\Newtonsoft.Json.xml" commentsOnly="False" />
+ </assemblies>
+ <namespaceSummaries>
+ <namespaceSummaryItem name="" isDocumented="False" />
+ <namespaceSummaryItem name="Newtonsoft.Json" isDocumented="True">The &lt;b&gt;Newtonsoft.Json&lt;/b&gt; namespace provides classes that are used to implement the core services of the framework.</namespaceSummaryItem>
+ <namespaceSummaryItem name="Newtonsoft.Json.Converters" isDocumented="True">The &lt;b&gt;Newtonsoft.Json.Converters&lt;/b&gt; namespace provides classes that inherit from &lt;a href="T_Newtonsoft_Json_JsonConverter.htm"&gt;JsonConverter&lt;/a&gt;.</namespaceSummaryItem>
+ <namespaceSummaryItem name="Newtonsoft.Json.Linq" isDocumented="True">The &lt;b&gt;Newtonsoft.Json.Linq&lt;/b&gt; namespace provides classes that are used to implement LINQ to JSON.</namespaceSummaryItem>
+ <namespaceSummaryItem name="Newtonsoft.Json.Utilities" isDocumented="True" />
+ </namespaceSummaries>
+ <additionalContent>
+ <contentItem sourcePath=".\SerializingJSON.html" destPath="" excludeItems="False" />
+ <contentItem sourcePath=".\styles.css" destPath="" excludeItems="False" />
+ <contentItem sourcePath=".\custom.css" destPath="" excludeItems="False" />
+ <contentItem sourcePath=".\LINQtoJSON.html" destPath="" excludeItems="False" />
+ <contentItem sourcePath=".\ReadingWritingJSON.html" destPath="" excludeItems="False" />
+ </additionalContent>
+ <ProjectSummary />
+ <MissingTags>Summary, Parameter, Returns, AutoDocumentCtors, Namespace</MissingTags>
+ <VisibleItems>InheritedMembers, InheritedFrameworkMembers, Protected, SealedProtected</VisibleItems>
+ <HtmlHelp1xCompilerPath path="" />
+ <HtmlHelp2xCompilerPath path="" />
+ <OutputPath>.\Output\</OutputPath>
+ <SandcastlePath path="" />
+ <WorkingPath path="" />
+ <CleanIntermediates>True</CleanIntermediates>
+ <KeepLogFile>True</KeepLogFile>
+ <HelpFileFormat>Help1xAndWebsite</HelpFileFormat>
+ <PurgeDuplicateTopics>True</PurgeDuplicateTopics>
+ <CppCommentsFixup>False</CppCommentsFixup>
+ <FrameworkVersion>3.5</FrameworkVersion>
+ <BinaryTOC>True</BinaryTOC>
+ <IncludeFavorites>False</IncludeFavorites>
+ <Preliminary>False</Preliminary>
+ <RootNamespaceContainer>False</RootNamespaceContainer>
+ <RootNamespaceTitle />
+ <HelpTitle>Json.NET - Quick Starts &amp; API Documentation</HelpTitle>
+ <HtmlHelpName>Documentation</HtmlHelpName>
+ <Language>en-US</Language>
+ <CopyrightHref />
+ <CopyrightText />
+ <FeedbackEMailAddress />
+ <HeaderText />
+ <FooterText />
+ <ProjectLinkType>Local</ProjectLinkType>
+ <SdkLinkType>Msdn</SdkLinkType>
+ <SdkLinkTarget>Blank</SdkLinkTarget>
+ <PresentationStyle>Prototype</PresentationStyle>
+ <NamingMethod>MemberName</NamingMethod>
+ <SyntaxFilters>Standard</SyntaxFilters>
+ <ShowFeedbackControl>False</ShowFeedbackControl>
+ <ContentPlacement>AboveNamespaces</ContentPlacement>
+ <ContentSiteMap path=".\doc.sitemap" />
+ <TopicFileTransform path="" />
+</project>
View
6 Src/Doc/doc.sitemap
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
+ <siteMapNode title="Serializing and deserializing JSON" url=".\SerializingJSON.html" isDefault="true" />
+ <siteMapNode title="LINQ to JSON" url=".\LINQtoJSON.html" />
+ <siteMapNode title="Reading and Writing JSON" url=".\ReadingWritingJSON.html" />
+</siteMap>
View
439 Src/Doc/styles.css
@@ -0,0 +1,439 @@
+/* page style */
+
+body {
+ margin: 0;
+ background-color: #FFFFFF;
+ padding: 0;
+ font-size: 8.5pt;
+ font-family: verdana, arial, sans-serif;
+ color: #000000;
+}
+
+html>body {
+ margin: 0;
+ background-color: #FFFFFF;
+ padding: 0;
+ font-size: 8.5pt;
+ font-family: verdana, arial, sans-serif;
+ color: #000000;
+ overflow: auto;
+}
+
+table {
+ /* this is a trick to force tables to inherit the body font size */
+ font-size: 100%;
+}
+
+/* non-scrolling (control) region style */
+
+div#control {
+ margin: 0;
+ background-color: #D4DFFF;
+ padding: 4px;
+ width: 100%;
+ border-bottom-color: #C8CDDE;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ z-index: 2;
+}
+
+span.productTitle {
+ font-size: 80%;
+}
+
+span.topicTitle {
+ font-size: 140%;
+ font-weight: bold;
+ color: #003399;
+}
+
+span#chickenFeet {
+ float: left;
+}
+
+span#languageFilter {
+ float: right;
+ height: 1px;
+ max-height: 1px;
+ vertical-align: bottom;
+ overflow: visible;
+}
+
+/* scrolling (content) region style */
+
+div#main
+{
+ clear: both;
+ margin: 0;
+ padding: 1em;
+ width: 100%;
+ z-index: 1;
+ overflow: auto;
+}
+
+/* sections */
+
+div#header {
+ font-size: 80%;
+ color: #666666;
+ margin-bottom: 0.5em;
+}
+
+div.summary {
+ margin-top: 0em;
+ margin-bottom: 1em;
+}
+
+div.section {
+ margin-bottom: 1em;
+}
+
+div.sectionTitle {
+ display: inline;
+ font-size: 120%;
+ font-weight: bold;
+ color: #003399;
+}
+
+div.sectionContent {
+ margin-top: 0.2em;
+}
+
+span.subsectionTitle {
+ font-weight: bold;
+}
+
+div#footer {
+ margin-top: 1em;
+ border-top: thin solid #003399;
+ padding-top: 0.5em;
+}
+
+div#footer p {
+ margin-top: 0.2em;
+ margin-bottom: 0.2em;
+}
+
+/* authored content (block) */
+
+p {
+ margin-top: 1em;
+ margin-bottom: 1em;
+}
+
+dl, ul, ol {
+ margin-top: 0.5em;
+ margin-bottom: 0.5em;
+}
+
+pre {
+ margin: 0;
+ padding: 0;
+ font-family: "Andale Mono", "Courier New", Courier, monospace;
+}
+
+table.authoredTable {
+ table-layout: fixed;
+ width: 100%;
+ margin-bottom: 1em;
+}
+
+table.authoredTable th {
+ border-bottom-color: #C8CDDE;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+}
+
+table.authoredTable td {
+ border-bottom-style: solid;
+ border-bottom-color: #C8CDDE;
+ border-bottom-width: 1px;
+ background: #F7F7FF;
+ padding: 0.2em;
+ vertical-align: top;
+}
+
+div.alert {
+ border: 1px solid #C8CDDE;
+ background: #F7F7FF;
+}
+
+div.media {
+ text-align: center;
+ margin-bottom: 1em;
+}
+
+
+/* authored content (inline) */
+
+span.keyword {
+ font-weight: bold;
+}
+
+span.code {
+ font-family: "Andale Mono", "Courier New", Courier, monospace;
+ font-size: 110%;
+ color: #000066;
+}
+
+/* auto-generated controls */
+
+div.langTabs {
+ /*width: 100%;*/
+}
+
+div.langTab {
+ float: left;
+ width: 15%;
+ border-top: 1px solid #C8CDDE;
+ border-left: 1px solid #C8CDDE;
+ border-right: 1px solid #C8CDDE;
+ background: #F7F7FF;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: normal;
+}
+
+div.activeLangTab {
+ float: left;
+ width: 15%;
+ border-top: 1px solid #C8CDDE;
+ border-left: 1px solid #C8CDDE;
+ border-right: 1px solid #C8CDDE;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+}
+
+table.members {
+ /* table-layout: fixed; */
+ width: 100%;
+}
+
+table.members th.iconColumn {
+ width: 60px;
+}
+
+table.members th.nameColumn {
+ width: 40%;
+}
+
+table.members th.descriptionColumn {
+ width: 60%;
+}
+
+table.members th {
+ border-bottom-color: #C8CDDE;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+}
+
+table.members td {
+ border-bottom-style: solid;
+ border-bottom-color: #C8CDDE;
+ border-bottom-width: 1px;
+ background: #F7F7FF;
+ padding: 0.2em;
+ vertical-align: top;
+ overflow: hidden;
+}
+
+table.exceptions {
+ table-layout: fixed;
+ width: 100%;
+}
+
+
+table.exceptions th.exceptionNameColumn {
+ width: 40%;
+}
+
+table.exceptions th.exceptionConditionColumn {
+ width: 60%;
+}
+
+table.exceptions th {
+ border-bottom-color: #C8CDDE;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+}
+
+table.exceptions td {
+ border-bottom-style: solid;
+ border-bottom-color: #C8CDDE;
+ border-bottom-width: 1px;
+ background: #F7F7FF;
+ padding: 0.2em;
+ vertical-align: top;
+}
+
+table.permissions {
+ table-layout: fixed;
+ width: 100%;
+}
+
+
+table.permissions th.permissionNameColumn {
+ width: 40%;
+}
+
+table.permissions th.permissionConditionColumn {
+ width: 60%;
+}
+
+table.permissions th {
+ border-bottom-color: #C8CDDE;
+ border-bottom-style: solid;
+ border-bottom-width: 1px;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+}
+
+table.permissions td {
+ border-bottom-style: solid;
+ border-bottom-color: #C8CDDE;
+ border-bottom-width: 1px;
+ background: #F7F7FF;
+ padding: 0.2em;
+ vertical-align: top;
+}
+
+span.obsolete {
+ color: red;
+}
+
+span.cs {
+ display: inline;
+}
+
+span.vb {
+ display: none;
+}
+
+span.cpp {
+ display: none;
+}
+
+span.nu
+{
+ display: none;
+}
+
+/* syntax styling */
+
+div.code span.identifier {
+ font-weight: bold;
+}
+
+div.code span.keyword {
+ color: green;
+}
+
+div.code span.parameter {
+ font-style: italic;
+ color: purple;
+}
+
+div.code span.literal {
+ color: purple;
+}
+
+div.code span.comment {
+ color: red;
+}
+
+span.foreignPhrase {
+ font-style: italic;
+}
+
+span.placeholder {
+ font-style: italic;
+}
+
+span.parameter
+{
+ font-style: italic;
+}
+
+span.typeparameter
+{
+ font-style: italic;
+}
+
+a {
+ color: blue;
+ text-decoration: none;
+}
+
+a:hover {
+ text-decoration: underline;
+}
+
+MSHelp\:link {
+ color: blue;
+ hoverColor: #3366ff;
+}
+
+span.nolink {
+ font-weight: bold;
+}
+
+span.selflink {
+ font-weight: bold;
+}
+
+table.filter {
+ table-layout: fixed;
+}
+
+tr.tabs td.tab {
+ width: 10em;
+ background: #F7F7FF;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: normal;
+ overflow: hidden;
+ cursor: pointer;
+}
+
+tr.tabs td.activeTab {
+ width: 10em;
+ background: #EFEFF7;
+ padding: 0.2em;
+ text-align: left;
+ color: #000066;
+ font-weight: bold;
+ overflow: hidden;
+}
+
+td.line {
+ background: #EFEFF7;
+}
+
+dt {
+ font-weight: bold;
+ margin-top: 10px;
+ margin-left: 10px;
+}
View
21 Src/Newtonsoft.Json.Tests/JsonSerializerTest.cs
@@ -38,6 +38,7 @@
using System.Web.Script.Serialization;
using Newtonsoft.Json.Linq;
using System.Linq;
+using Newtonsoft.Json.Converters;
namespace Newtonsoft.Json.Tests
{
@@ -231,7 +232,7 @@ public void TypedObjectDeserialization()
string output = JavaScriptConvert.SerializeObject(product);
//{
// "Name": "Apple",
- // "Expiry": new Date(1230422400000),
+ // "Expiry": "\/Date(1230375600000+1300)\/",
// "Price": 3.99,
// "Sizes": [
// "Small",
@@ -250,6 +251,24 @@ public void TypedObjectDeserialization()
Assert.AreEqual("Large", deserializedProduct.Sizes[2]);
}
+ //[Test]
+ //public void Advanced()
+ //{
+ // Product product = new Product();
+ // product.Expiry = new DateTime(2008, 12, 28);
+
+ // JsonSerializer serializer = new JsonSerializer();
+ // serializer.Converters.Add(new JavaScriptDateTimeConverter());
+ // serializer.NullValueHandling = NullValueHandling.Ignore;
+
+ // using (StreamWriter sw = new StreamWriter(@"c:\json.txt"))
+ // using (JsonWriter writer = new JsonTextWriter(sw))
+ // {
+ // serializer.Serialize(writer, product);
+ // // {"Expiry":new Date(1230375600000),"Price":0}
+ // }
+ //}
+
[Test]
public void JavaScriptConvertSerializer()
{
View
11 Src/Newtonsoft.Json.Tests/JsonTextWriterTest.cs
@@ -119,6 +119,17 @@ public void Indenting()
jsonWriter.WriteEndObject();
}
+ // {
+ // "CPU": "Intel",
+ // "PSU": "500W",
+ // "Drives": [
+ // "DVD read/writer"
+ // /*(broken)*/,
+ // "500 gigabyte hard drive",
+ // "200 gigabype hard drive"
+ // ]
+ // }
+
string expected = @"{
""CPU"": ""Intel"",
""PSU"": ""500W"",
View
44 Src/Newtonsoft.Json.Tests/Linq/LinqToJsonTest.cs
@@ -38,15 +38,47 @@ namespace Newtonsoft.Json.Tests.Linq
public class LinqToJsonTest : TestFixtureBase
{
[Test]
+ public void Manual()
+ {
+ JArray array = new JArray();
+ JValue text = new JValue("Manual text");
+ JValue date = new JValue(new DateTime(2000, 5, 23));
+
+ array.Add(text);
+ array.Add(date);
+
+ string json = array.ToString();
+ // [
+ // "Manual text",
+ // "\/Date(958996800000+1200)\/"
+ // ]
+ }
+
+ [Test]
+ public void LinqToJsonDeserialize()
+ {
+ JObject o = new JObject(
+ new JProperty("Name", "John Smith"),
+ new JProperty("BirthDate", new DateTime(1983, 3, 20))
+ );
+
+ JsonSerializer serializer = new JsonSerializer();
+ Person p = (Person)serializer.Deserialize(new JsonTokenReader(o), typeof(Person));
+
+ // John Smith
+ Console.WriteLine(p.Name);
+ }
+
+ [Test]
public void ObjectParse()
{
string json = @"{
- CPU: 'Intel',
- Drives: [
- 'DVD read/writer',
- ""500 gigabyte hard drive""
- ]
-}";
+ CPU: 'Intel',
+ Drives: [
+ 'DVD read/writer',
+ ""500 gigabyte hard drive""
+ ]
+ }";
JObject o = JObject.Parse(json);
IList<JProperty> properties = o.Properties().ToList();
View
11 Src/Newtonsoft.Json.sln
@@ -11,6 +11,17 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json", "Newtonso
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Newtonsoft.Json.Tests", "Newtonsoft.Json.Tests\Newtonsoft.Json.Tests.csproj", "{3E6E2335-B079-4B5B-A65A-9D586914BCBB}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Doc", "Doc", "{8F9E13D9-4181-4BA6-8802-EB5B3EB9445A}"
+ ProjectSection(SolutionItems) = preProject
+ Doc\custom.css = Doc\custom.css
+ Doc\doc.shfb = Doc\doc.shfb
+ Doc\doc.sitemap = Doc\doc.sitemap
+ Doc\LINQtoJSON.html = Doc\LINQtoJSON.html
+ Doc\ReadingWritingJSON.html = Doc\ReadingWritingJSON.html
+ Doc\SerializingJSON.html = Doc\SerializingJSON.html
+ Doc\styles.css = Doc\styles.css
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
View
2 Src/Newtonsoft.Json/Converters/IsoDateTimeConverter.cs
@@ -8,7 +8,7 @@
namespace Newtonsoft.Json.Converters
{
/// <summary>
- /// Converts text in the ISO 8601 date format to and from JSON.
+ /// Converts a <see cref="DateTime"/> to and from the ISO 8601 date format (e.g. 2008-04-12T12:53Z).
/// </summary>
public class IsoDateTimeConverter : JsonConverter
{
View
2 Src/Newtonsoft.Json/Converters/XmlNodeConverter.cs
@@ -34,7 +34,7 @@
namespace Newtonsoft.Json.Converters
{
/// <summary>
- /// Converts an XmlNode to and from JSON.
+ /// Converts an <see cref="XmlNode"/> to and from JSON.
/// </summary>
public class XmlNodeConverter : JsonConverter
{
View
2 Src/Newtonsoft.Json/JsonReader.cs
@@ -203,7 +203,7 @@ private JsonTokenType Peek()
/// <summary>
/// Reads the next Json token from the stream.
/// </summary>
- /// <returns></returns>
+ /// <returns>true if the next token was read successfully; false if there are no more tokens to read.</returns>
public abstract bool Read();
/// <summary>
View
9 Src/Newtonsoft.Json/JsonSerializer.cs
@@ -68,7 +68,7 @@ public ReferenceLoopHandling ReferenceLoopHandling
}
/// <summary>
- /// Get or set how missing members are handled during deserialization.
+ /// Get or set how missing members (e.g. JSON contains a property that isn't a member on the object) are handled during deserialization.
/// </summary>
public MissingMemberHandling MissingMemberHandling
{
@@ -83,7 +83,7 @@ public MissingMemberHandling MissingMemberHandling
}
/// <summary>
- /// Get or set how null values are handled.
+ /// Get or set how null values are handled during serialization and deserialization.
/// </summary>
public NullValueHandling NullValueHandling
{
@@ -98,7 +98,7 @@ public NullValueHandling NullValueHandling
}
/// <summary>
- /// Gets or sets how objects are created.
+ /// Gets or sets how objects are created during deserialization.
/// </summary>
/// <value>The object creation handling.</value>
public ObjectCreationHandling ObjectCreationHandling
@@ -513,10 +513,9 @@ private object CreateAndPopulateObject(JsonReader reader, Type objectType)
ConstructorInfo c = objectType.GetConstructors(BindingFlags.Public | BindingFlags.Instance).SingleOrDefault();
if (c == null)
- throw new Exception("sdsdf");
+ throw new JsonSerializationException("Could not find a public constructor for type {0}.".FormatWith(CultureInfo.InvariantCulture, objectType));
IDictionary<ParameterInfo, object> constructorParameters = c.GetParameters().ToDictionary(p => p, p => (object)null);
- //IList<object> constructorValues
bool exit = false;
while (!exit && reader.Read())
View
6 Src/Newtonsoft.Json/JsonTextReader.cs
@@ -262,7 +262,9 @@ private bool MoveTo(char value)
/// <summary>
/// Reads the next Json token from the stream.
/// </summary>
- /// <returns></returns>
+ /// <returns>
+ /// true if the next token was read successfully; false if there are no more tokens to read.
+ /// </returns>
public override bool Read()
{
while (true)
@@ -792,7 +794,7 @@ private void ParseNumberNaN()
}
/// <summary>
- /// Changes the <see cref="P:State"/> to Closed.
+ /// Changes the <see cref="P:CurrentState"/> to Closed.
/// </summary>
public override void Close()
{
View
4 Src/Newtonsoft.Json/JsonTextWriter.cs
@@ -179,11 +179,11 @@ protected override void WriteEnd(JsonToken token)
throw new JsonWriterException("Invalid JsonToken: " + token);
}
}
-
+
/// <summary>
/// Writes the property name of a name/value pair on a Json object.
/// </summary>
- /// <param name="name"></param>
+ /// <param name="name">The name of the property.</param>
public override void WritePropertyName(string name)
{
base.WritePropertyName(name);
View
2 Src/Newtonsoft.Json/JsonWriter.cs
@@ -287,7 +287,7 @@ public void WriteEndConstructor()
/// <summary>
/// Writes the property name of a name/value pair on a Json object.
/// </summary>
- /// <param name="name"></param>
+ /// <param name="name">The name of the property.</param>
public virtual void WritePropertyName(string name)
{
AutoComplete(JsonToken.PropertyName);
View
2 Src/Newtonsoft.Json/Linq/JArray.cs
@@ -95,7 +95,7 @@ internal override JToken CloneNode()
/// <summary>
/// Returns a count of this token's child tokens.
/// </summary>
- /// <returns></returns>
+ /// <returns>A count of this token's child tokens.</returns>
public int Count()
{
return Children().Count();
View
4 Src/Newtonsoft.Json/Linq/JValue.cs
@@ -172,7 +172,7 @@ internal override JToken CloneNode()
/// Creates a <see cref="JValue"/> comment with the given value.
/// </summary>
/// <param name="value">The value.</param>
- /// <returns></returns>
+ /// <returns>A <see cref="JValue"/> comment with the given value.</returns>
public static JValue CreateComment(string value)
{
return new JValue(value, JsonTokenType.Comment);
@@ -182,7 +182,7 @@ public static JValue CreateComment(string value)
/// Creates a <see cref="JValue"/> string with the given value.
/// </summary>
/// <param name="value">The value.</param>
- /// <returns></returns>
+ /// <returns>A <see cref="JValue"/> string with the given value.</returns>
public static JValue CreateString(string value)
{
return new JValue(value, JsonTokenType.String);
View
4 Src/Newtonsoft.Json/Linq/JsonTokenReader.cs
@@ -30,7 +30,9 @@ public JsonTokenReader(JToken token)
/// <summary>
/// Reads the next Json token from the stream.
/// </summary>
- /// <returns></returns>
+ /// <returns>
+ /// true if the next token was read successfully; false if there are no more tokens to read.
+ /// </returns>
public override bool Read()
{
if (CurrentState != State.Start)
View
2 Src/Newtonsoft.Json/Linq/JsonTokenWriter.cs
@@ -118,7 +118,7 @@ protected override void WriteEnd(JsonToken token)
/// <summary>
/// Writes the property name of a name/value pair on a Json object.
/// </summary>
- /// <param name="name"></param>
+ /// <param name="name">The name of the property.</param>
public override void WritePropertyName(string name)
{
base.WritePropertyName(name);

0 comments on commit d88e2cf

Please sign in to comment.
Something went wrong with that request. Please try again.