<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.newtonking.com/~d/styles/itemcontent.css"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>James Newton-King</title><link>http://james.newtonking.com/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2008.5 SP1 (Build: 31106.3070)</generator><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.newtonking.com/jamesnewtonking" /><feedburner:info uri="jamesnewtonking" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item><title>Json.NET 4.0 Release 6 – Serialization Performance</title><link>http://feeds.newtonking.com/~r/jamesnewtonking/~3/1gzKuUJQvdQ/json-net-4-0-release-6-serialization-performance.aspx</link><pubDate>Mon, 23 Jan 2012 08:03:25 GMT</pubDate><guid isPermaLink="false">bce7ef4a-1ab4-4a64-ae34-bb54d1362c7e:57392</guid><dc:creator>James Newton-King</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;The big feature of this release is improved performance. For the first time in a couple of years I’ve sat down and benchmarked, profiled and tuned Json.NET.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="And now, in the spirit of the season: start shopping. And for every dollar of Krusty merchandise you buy, I will be nice to a sick kid. For legal purposes, sick kids may include hookers with a cold." border="0" alt="And now, in the spirit of the season: start shopping. And for every dollar of Krusty merchandise you buy, I will be nice to a sick kid. For legal purposes, sick kids may include hookers with a cold." src="http://james.newtonking.com/images/Json.NET-4.0-Release-4--Bug-fixes_DA7F/json406jsonperformance.png" width="592" height="336" /&gt;&lt;/p&gt;  &lt;p&gt;For all its features Json.NET was already fast but there are improvements in JsonTextReader which I rewrote and object deserilization. Json.NET is faster than both .NET framework JSON serializers in all scenarios again.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Improved error messages&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One of the nice features of JsonTextReader is that it keeps track of its current line number and line position and includes that information when it encounters bad JSON.&lt;/p&gt;  &lt;p&gt;This release adds that line number and position information to deserialization errors. Now deserialization should be much easier to troubleshoot.&lt;/p&gt;  &lt;div class="overflowpanel"&gt;   &lt;div class="code"&gt;     &lt;div style="font-family:consolas;color:black;font-size:10pt;"&gt;       &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; json = &lt;span style="color:#a31515;"&gt;@&amp;quot;[&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;&amp;#160; 1,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;&amp;#160; 2,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;&amp;#160; 3,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;&amp;#160; null&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#a31515;"&gt;]&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;&amp;gt; numbers = &lt;span style="color:#2b91af;"&gt;JsonConvert&lt;/span&gt;.DeserializeObject&amp;lt;&lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;int&lt;/span&gt;&amp;gt;&amp;gt;(json);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// Error converting value {null} to type &amp;#39;System.Int32&amp;#39;. Line 5, position 7.&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Worst. Bug. Ever. Fixed.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Visual Studio Ultimate Edition has a feature called &lt;a href="http://msdn.microsoft.com/en-us/library/dd264915.aspx" target="_blank"&gt;Intellitrace&lt;/a&gt;. Intellitrace and Json.NET &lt;a href="https://www.google.com/search?q=json.net+intellitrace+operation+could+destabilize+the+runtime" target="_blank"&gt;didn’t get along&lt;/a&gt;. After a year of at first being unsure why only some people were getting the error, and then not knowing what exactly why Intellitrace was breaking Json.NET, I finally nailed it down to one three line method that Intellitrace didn’t like. &lt;a href="http://json.codeplex.com/SourceControl/changeset/changes/64489" target="_blank"&gt;Fixed... finally&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a complete list of what has changed since Json.NET 4.0 Release 4 (if you’re curious where v5 is, it was just one fix for Windows Phone Mango and NuGet).&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New feature - Added line number information to deserialization errors &lt;/li&gt;

  &lt;li&gt;New feature - Added ReadAsInt32 to JsonReader &lt;/li&gt;

  &lt;li&gt;New feature - Added BinaryReader/BinaryWriter constructor overloads to BsonReader/BsonWriter &lt;/li&gt;

  &lt;li&gt;Change - JsonTextReader error message when additional JSON content found is more descriptive &lt;/li&gt;

  &lt;li&gt;Fix - Removed unused utility methods &lt;/li&gt;

  &lt;li&gt;Fix - Fixed elusive Intellitrace runtime destabilization error &lt;/li&gt;

  &lt;li&gt;Fix - Fixed internal exception thrown when deserializing Decimal/DateTimeOffset/Byte lists &lt;/li&gt;

  &lt;li&gt;Fix - Fixed potential multi-threading serializing issue &lt;/li&gt;

  &lt;li&gt;Fix - Fixed serializing types that hides a base classes property with a proeprty of the same name &lt;/li&gt;

  &lt;li&gt;Fix - Fixed BsonReader to use BinaryReader instead of base stream &lt;/li&gt;

  &lt;li&gt;Fix - Fixed referencing the NuGet package from Windows Phone 7.1 projects &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/"&gt;Json.NET CodePlex Project&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/releases/view/80975"&gt;Json.NET 4.0 Release 6 Download&lt;/a&gt;&lt;/strong&gt; – Json.NET source code, documentation and binaries&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://james.newtonking.com/aggbug.aspx?PostID=57392" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/jamesnewtonking/~4/1gzKuUJQvdQ" height="1" width="1"/&gt;</description><category domain="http://james.newtonking.com/archive/tags/Json.NET/default.aspx">Json.NET</category><category domain="http://james.newtonking.com/archive/tags/Project/default.aspx">Project</category><feedburner:origLink>http://james.newtonking.com/archive/2012/01/23/json-net-4-0-release-6-serialization-performance.aspx</feedburner:origLink></item><item><title>Json.NET 4.0 Release 4 – Bug fixes</title><link>http://feeds.newtonking.com/~r/jamesnewtonking/~3/4ZeUTDSAhqs/json-net-4-0-release-4-bug-fixes.aspx</link><pubDate>Sat, 19 Nov 2011 09:33:52 GMT</pubDate><guid isPermaLink="false">bce7ef4a-1ab4-4a64-ae34-bb54d1362c7e:57391</guid><dc:creator>James Newton-King</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;This release contains bug fixes and some minor changes.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Custom type names with TypeNameHandling&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;em&gt;Note that support for custom type names was added in a previous Json.NET release.&lt;/em&gt;&lt;/p&gt;  &lt;p&gt;One commonly asked for feature is the ability to customize the value of the $type property when using TypeNameHandling. Fortunately new in .NET 4 is the virtual &lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.serializationbinder.bindtoname.aspx" target="_blank"&gt;SerializationBinder.BindToName&lt;/a&gt; method that translates a Type to a custom string.&lt;/p&gt;  &lt;p&gt;To customize the $type property in Json.NET just create a class that inherits from SerializationBinder and override the BindToName and the BindToType methods with your custom naming logic. The example SerializationBinder example below serializes types to just their name without any namespace or assembly information, those details are passed into the binder itself via a constructor parameter and used during deserialization.&lt;/p&gt;  &lt;div class="overflowpanel"&gt;   &lt;div class="code"&gt;     &lt;div style="font-family:courier new;color:black;font-size:10pt;"&gt;       &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TypeNameSerializationBinder&lt;/span&gt; : &lt;span style="color:#2b91af;"&gt;SerializationBinder&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;{&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; TypeFormat { &lt;span style="color:blue;"&gt;get&lt;/span&gt;; &lt;span style="color:blue;"&gt;private&lt;/span&gt; &lt;span style="color:blue;"&gt;set&lt;/span&gt;; }&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; TypeNameSerializationBinder(&lt;span style="color:blue;"&gt;string&lt;/span&gt; typeFormat)&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; TypeFormat = typeFormat;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; }&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:blue;"&gt;void&lt;/span&gt; BindToName(&lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; serializedType, &lt;span style="color:blue;"&gt;out&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; assemblyName, &lt;span style="color:blue;"&gt;out&lt;/span&gt; &lt;span style="color:blue;"&gt;string&lt;/span&gt; typeName)&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; assemblyName = &lt;span style="color:blue;"&gt;null&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; typeName = serializedType.Name;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; }&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; &lt;span style="color:blue;"&gt;public&lt;/span&gt; &lt;span style="color:blue;"&gt;override&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt; BindToType(&lt;span style="color:blue;"&gt;string&lt;/span&gt; assemblyName, &lt;span style="color:blue;"&gt;string&lt;/span&gt; typeName)&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;string&lt;/span&gt; resolvedTypeName = &lt;span style="color:blue;"&gt;string&lt;/span&gt;.Format(TypeFormat, typeName);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;return&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Type&lt;/span&gt;.GetType(resolvedTypeName, &lt;span style="color:blue;"&gt;true&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; }&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;}&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The simplest way to use a custom serialization binder is with JsonConvert and JsonSerializerSettings.&lt;/p&gt;

&lt;div class="overflowpanel"&gt;
  &lt;div class="code"&gt;
    &lt;div style="font-family:courier new;color:black;font-size:10pt;"&gt;
      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;TypeNameSerializationBinder&lt;/span&gt; binder = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;TypeNameSerializationBinder&lt;/span&gt;(&lt;span style="color:#a31515;"&gt;&amp;quot;YourAppNamespace.{0}, YourAppAssembly&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;IList&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;object&lt;/span&gt;&amp;gt; values = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="color:blue;"&gt;object&lt;/span&gt;&amp;gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Customer&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Caroline Customer&amp;quot;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; },&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;Purchase&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; ProductName = &lt;span style="color:#a31515;"&gt;&amp;quot;Elbow Grease&amp;quot;&lt;/span&gt;,&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Price = 5.99m,&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Quantity = 1&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; };&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; json = &lt;span style="color:#2b91af;"&gt;JsonConvert&lt;/span&gt;.SerializeObject(values, &lt;span style="color:#2b91af;"&gt;Formatting&lt;/span&gt;.Indented, &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JsonSerializerSettings&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;{&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; TypeNameHandling = &lt;span style="color:#2b91af;"&gt;TypeNameHandling&lt;/span&gt;.Auto,&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160; Binder = binder&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;});&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//[&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160; {&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;$type&amp;quot;: &amp;quot;Customer&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;Name&amp;quot;: &amp;quot;Caroline Customer&amp;quot;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160; },&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160; {&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;$type&amp;quot;: &amp;quot;Purchase&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;ProductName&amp;quot;: &amp;quot;Elbow Grease&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;Price&amp;quot;: 5.99,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160; &amp;quot;Quantity&amp;quot;: 1&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160; }&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//]&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;To deserialize just reuse the custom SerializationBinder with DeserializeObject.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a complete list of what has changed since Json.NET 4.0 Release 3.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Change - JsonTextReader.Culture is now CultureInfo.InvariantCulture by default &lt;/li&gt;

  &lt;li&gt;Change - KeyValurPairConverter no longer depends on the order of the key and value properties &lt;/li&gt;

  &lt;li&gt;Change - Time zone conversions now use new TimeZoneInfo instead of TimeZone &lt;/li&gt;

  &lt;li&gt;Fix - Fixed boolean values sometimes being capitalized when converting to XML &lt;/li&gt;

  &lt;li&gt;Fix - Fixed error when deserializing ConcurrentDictionary &lt;/li&gt;

  &lt;li&gt;Fix - Fixed serializing some Uris returning the incorrect value &lt;/li&gt;

  &lt;li&gt;Fix - Fixed occasional error when converting non-long integer properties to XML &lt;/li&gt;

  &lt;li&gt;Fix - Fixed deserializing byte arrays with type name information &lt;/li&gt;

  &lt;li&gt;Fix - Fixed flag enum items not being correctly camel cased &lt;/li&gt;

  &lt;li&gt;Fix - Fixed JsonValidatingReader validating the first array item twice &lt;/li&gt;

  &lt;li&gt;Fix - Fixed JsonSchema not correctly validating integers as a subset of decimal &lt;/li&gt;

  &lt;li&gt;Fix - Fixed bad BSON when writing long strings of complex UTF8 characters &lt;/li&gt;

  &lt;li&gt;Fix - Fixed error not being raised for additional content in JSON string for JArray.Parse and JObject.Parse &lt;/li&gt;

  &lt;li&gt;Fix - Fixed DataTableConverter including nulls with NullValueHandling.Ignore &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/" target="_blank"&gt;Json.NET CodePlex Project&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/releases/view/77129" target="_blank"&gt;Json.NET 4.0 Release 4 Download&lt;/a&gt;&lt;/strong&gt; – Json.NET source code, documentation and binaries&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://james.newtonking.com/aggbug.aspx?PostID=57391" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/jamesnewtonking/~4/4ZeUTDSAhqs" height="1" width="1"/&gt;</description><category domain="http://james.newtonking.com/archive/tags/Json.NET/default.aspx">Json.NET</category><category domain="http://james.newtonking.com/archive/tags/Project/default.aspx">Project</category><feedburner:origLink>http://james.newtonking.com/archive/2011/11/19/json-net-4-0-release-4-bug-fixes.aspx</feedburner:origLink></item><item><title>Json.NET 4.0 Release 3 – LINQ to JSON performance</title><link>http://feeds.newtonking.com/~r/jamesnewtonking/~3/yImRx0YU5pw/json-net-4-0-release-3-linq-to-json-performance.aspx</link><pubDate>Sun, 02 Oct 2011 03:05:11 GMT</pubDate><guid isPermaLink="false">bce7ef4a-1ab4-4a64-ae34-bb54d1362c7e:56996</guid><dc:creator>James Newton-King</dc:creator><slash:comments>9</slash:comments><comments>http://james.newtonking.com/archive/2011/10/01/json-net-4-0-release-3-linq-to-json-performance.aspx#comments</comments><description>&lt;p&gt;One of Json.NET’s most popular features - LINQ to JSON – has gotten a speed boost.&lt;/p&gt;  &lt;p&gt;Previously the LINQ to JSON collection objects (JObject and JArray) internally used a linked list to keep track of their children. While this gave them complete control over the order of properties inside objects, it made lookups by key (a property name for an object, an index for an array) slow over large JSON documents.&lt;/p&gt;  &lt;p&gt;Json.NET 4.0 Release 3 changes the internal structure of the collection objects to eliminate linked lists – JArray now uses a list internally to store child values and JObject uses a combination of a list and dictionary, letting it preserve property order and make property name lookups O(1).&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="I&amp;#39;ll have to read Marge&amp;#39;s book, and I swore never to read again after To Kill a Mockingbird gave me no useful advice on killing mockingbirds. It did teach me not to judge a man based on the color of his skin, but what good does that do me?" border="0" alt="I&amp;#39;ll have to read Marge&amp;#39;s book, and I swore never to read again after To Kill a Mockingbird gave me no useful advice on killing mockingbirds. It did teach me not to judge a man based on the color of his skin, but what good does that do me?" src="http://james.newtonking.com/images/Jso.0-Release-3--LINQ-to-JSON-performanc_B733/image.png" width="592" height="356" /&gt;&lt;/p&gt;  &lt;p&gt;From your perspective the API for LINQ to JSON is exactly the same, it is just faster.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Assembly file names&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One thing to note in this release is that to play nicely with &lt;a href="http://nuget.org/List/Packages/Newtonsoft.Json" target="_blank"&gt;NuGet&lt;/a&gt; the different versions of Json.NET now all use the same assembly file name: &lt;u&gt;Newtonsoft.Json.dll&lt;/u&gt;&lt;/p&gt;  &lt;p&gt;If you want to find out exactly which version of the dll you are using the Windows file properties dialog display’s a .NET assembly’s title as the File description.&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;padding-left:0px;padding-right:0px;display:inline;border-top:0px;border-right:0px;padding-top:0px;" title="Oh no, the Pawnee have returned. They probably want their souls back." border="0" alt="Oh no, the Pawnee have returned. They probably want their souls back." src="http://james.newtonking.com/images/Jso.0-Release-3--LINQ-to-JSON-performanc_B733/image_3.png" width="300" height="409" /&gt;&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Changes&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Here is a complete list of what has changed since Json.NET 4.0 Release 2.&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;New feature - Improved support for deserializing objects using non-default constructors&lt;/li&gt;    &lt;li&gt;New feature - JsonConverterAttribute now allowed on constructor parameters&lt;/li&gt;    &lt;li&gt;New feature - JsonPropertyAttribute now allowed on constructor parameters &lt;/li&gt;    &lt;li&gt;New feature - Added Serializable attribute to exceptions&lt;/li&gt;    &lt;li&gt;New feature - JsonObject and JsonProperty attributes can now be placed on an interface and used when serializing implementing objects &lt;/li&gt;    &lt;li&gt;New feature - Improve TypeNameHandling.Auto to skip adding an unneeded type name for collection interfaces &lt;/li&gt;    &lt;li&gt;New feature - LINQ to JSON internals rewritten to use lists and dictionaries rather than linked lists&lt;/li&gt;    &lt;li&gt;New feature - Added support for deserializing to readonly collections and dictionaries on classes with non-default constructors &lt;/li&gt;    &lt;li&gt;New feature - Added serialization constructors to all Exceptions&lt;/li&gt;    &lt;li&gt;New feature - Added support for serialization event attributes on base classes&lt;/li&gt;    &lt;li&gt;New feature - Added support for BindToName on SerializationBinder &lt;/li&gt;    &lt;li&gt;New feature - Missing JSON errors can now be handled using JsonSerializer error handling &lt;/li&gt;    &lt;li&gt;New feature - Added Populate and IgnoreAndPopulate options to DefaultValueHandling for automatically populating default values during deserialization&lt;/li&gt;    &lt;li&gt;New feature - Added support for setting readonly fields when marked up with JsonPropertyAttribute &lt;/li&gt;    &lt;li&gt;New feature - Added Order to JsonPropertyAttribute to override the order of serialized JSON &lt;/li&gt;    &lt;li&gt;New feature - Added Culture to JsonTextReader to use when converting values from JSON text &lt;/li&gt;    &lt;li&gt;New feature - Added support for reading byte arrays from JSON integer arrays &lt;/li&gt;    &lt;li&gt;New feature - Added support for deserializing IDictionary properties &lt;/li&gt;    &lt;li&gt;New feature - Added ToObject to JToken for deserializing LINQ to JSON objects to a .NET object&lt;/li&gt;    &lt;li&gt;New feature - Added support for Guid, TimeSpan and Uri to LINQ to JSON &lt;/li&gt;    &lt;li&gt;Change - Changed WriteEndObject, WriteEndArray, WriteEndConstructor on JsonWriter to be virtual &lt;/li&gt;    &lt;li&gt;Change - Moved JPropertyDescriptor to Newtonsoft.Json.Linq namespace &lt;/li&gt;    &lt;li&gt;Change - Additional content after the $ref property now ignored when reading schema references&lt;/li&gt;    &lt;li&gt;Change - Changed JToken.Children to return an empty iterator rather than erroring &lt;/li&gt;    &lt;li&gt;Change - Changed the assembly file names to all be Newtonsoft.Json.dll to fix NuGet referencing &lt;/li&gt;    &lt;li&gt;Change - Changed $id and $ref properties to allow null &lt;/li&gt;    &lt;li&gt;Fix - Changed .NET 2.0 version to use LinqBridge source code rather than ilmerge to fix error &lt;/li&gt;    &lt;li&gt;Fix - Fixed deserializing to IEnumerable&amp;lt;T&amp;gt; properties &lt;/li&gt;    &lt;li&gt;Fix - Fixed DataTable and DataColumn names not being modified by CamelCasePropertyNamesContractResolver &lt;/li&gt;    &lt;li&gt;Fix - Fixed JObject loading JSON with comments&lt;/li&gt;    &lt;li&gt;Fix - Fixed error when using a Specified property with no setter&lt;/li&gt;    &lt;li&gt;Fix - Fixed transient constructor error on Windows Phone 7&lt;/li&gt;    &lt;li&gt;Fix - Fixed deserializing null values into nullable generic dictionaries &lt;/li&gt;    &lt;li&gt;Fix - Fixed potential casting error when writing JSON using a JsonReader &lt;/li&gt;    &lt;li&gt;Fix - Fixed converting emtpy XML elements with an array attribute not writing other attributes&lt;/li&gt;    &lt;li&gt;Fix - Fixed deserializing null values into DataTables&lt;/li&gt;    &lt;li&gt;Fix - Fixed error when deserializing readonly IEnumerable&amp;lt;T&amp;gt; array properties&lt;/li&gt;    &lt;li&gt;Fix - Fixed not including type name for byte[] values &lt;/li&gt;    &lt;li&gt;Fix - Fixed BsonWriter failing silently when writing values outside of an Object or Array&lt;/li&gt;    &lt;li&gt;Fix - Fixed serializer attempting to use dynamic code generation in partial trust &lt;/li&gt;    &lt;li&gt;Fix - Fixed serializing objects with DataContract and DataMember attributes on base classes&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://json.codeplex.com/" target="_blank"&gt;&lt;strong&gt;Json.NET CodePlex Project&lt;/strong&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://json.codeplex.com/releases/view/74287" target="_blank"&gt;&lt;strong&gt;Json.NET 4.0 Release 3 Download&lt;/strong&gt;&lt;/a&gt; – Json.NET source code, documentation and binaries&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://james.newtonking.com/aggbug.aspx?PostID=56996" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/jamesnewtonking/~4/yImRx0YU5pw" height="1" width="1"/&gt;</description><category domain="http://james.newtonking.com/archive/tags/Json.NET/default.aspx">Json.NET</category><category domain="http://james.newtonking.com/archive/tags/Project/default.aspx">Project</category><feedburner:origLink>http://james.newtonking.com/archive/2011/10/01/json-net-4-0-release-3-linq-to-json-performance.aspx</feedburner:origLink></item><item><title>Json.NET 4.0 Release 2 – NuGet 1.2 and Dynamic</title><link>http://feeds.newtonking.com/~r/jamesnewtonking/~3/NnyXk6_reK0/json-net-4-0-release-2-nuget-1-2-and-dynamic.aspx</link><pubDate>Fri, 22 Apr 2011 03:19:27 GMT</pubDate><guid isPermaLink="false">bce7ef4a-1ab4-4a64-ae34-bb54d1362c7e:43800</guid><dc:creator>James Newton-King</dc:creator><slash:comments>32</slash:comments><comments>http://james.newtonking.com/archive/2011/04/21/json-net-4-0-release-2-nuget-1-2-and-dynamic.aspx#comments</comments><description>&lt;p&gt;This release builds on two areas introduced in Json.NET 4.0: NuGet and .NET 4 dynamic support.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;NuGet 1.2&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;&lt;img style="background-image:none;border-bottom:0px;border-left:0px;margin:0px 0px 5px 5px;padding-left:0px;padding-right:0px;display:inline;float:right;border-top:0px;border-right:0px;padding-top:0px;" title="I understand. Let us celebrate our agreement with the adding of chocolate to milk. " border="0" alt="I understand. Let us celebrate our agreement with the adding of chocolate to milk. " align="right" src="http://james.newtonking.com/images/Json.NET-4.0-Release-2_A6FE/contribGraphic_thumb.png" width="200" height="140" /&gt;&lt;a href="http://www.nuget.org/"&gt;NuGet&lt;/a&gt; is fast becoming the preferred way to install libraries in .NET. NuGet 1.2 was recently released and among other improvements it adds support for the Windows Phone.&lt;/p&gt;  &lt;p&gt;Json.NET 4.0 Release 2 has been updated to support NuGet 1.2 and Windows Phone – there is nothing you need to do, it should just work. Windows Phone brings Json.NET’s NuGet support up to 7 different frameworks:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;.NET 4 &lt;/li&gt;    &lt;li&gt;.NET 4 Client Profile &lt;/li&gt;    &lt;li&gt;.NET 3.5 &lt;/li&gt;    &lt;li&gt;.NET 3.5 Client Profile &lt;/li&gt;    &lt;li&gt;.NET 2 &lt;/li&gt;    &lt;li&gt;Silverlight 4 &lt;/li&gt;    &lt;li&gt;Windows Phone &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&lt;strong&gt;Dynamic Improvements&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Feedback on the initial release of dynamic support in Json.NET 4.0 was that values didn’t behave as expected. Concatenating two integers would throw an exception for example – less than ideal.&lt;/p&gt;  &lt;p&gt;Release 2 adds support for common value operations: comparing, adding, subtracting, multiplying, dividing, incrementing and decrementing all now work like they should.&lt;/p&gt;  &lt;div class="overflowpanel"&gt;   &lt;div class="code"&gt;     &lt;div style="font-family:courier new;color:black;font-size:10pt;"&gt;       &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;dynamic&lt;/span&gt; product = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JObject&lt;/span&gt;();&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.ProductName = &lt;span style="color:#a31515;"&gt;&amp;quot;Elbow Grease&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.Enabled = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.Price = 4.90m;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.StockCount = 9000;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.StockValue = 44100;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// All Elbow Grease must go sale!&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// 50% off price&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.Price = product.Price / 2;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.StockValue = product.StockCount * product.Price;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;product.ProductName = product.ProductName + &lt;span style="color:#a31515;"&gt;&amp;quot; (SALE)&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; json = product.ToString();&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// {&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;ProductName&amp;quot;: &amp;quot;Elbow Grease (SALE)&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;Enabled&amp;quot;: true,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;Price&amp;quot;: 2.45,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;StockCount&amp;quot;: 9000,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;StockValue&amp;quot;: 22050.0&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// }&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;And More&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Like always many smaller features has been added (&lt;a href="http://msdn.microsoft.com/en-us/library/system.runtime.serialization.enummemberattribute.aspx" target="_blank"&gt;EnumMemberAttribute&lt;/a&gt; serializer support for example) and bugs have been fixed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a complete list of what has changed since Json.NET 4.0 Release 1.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New feature - Added commonly used primitive value operations to dynamic JValue&lt;/li&gt;

  &lt;li&gt;New feature - Added IComparable to JValue&lt;/li&gt;

  &lt;li&gt;New feature - Added JsonConstructorAttribute to explicitly define which constructor to use during deserialization&lt;/li&gt;

  &lt;li&gt;New feature - Added IFormattable to JValue&lt;/li&gt;

  &lt;li&gt;New feature - Added Load and Parse helper methods to JToken&lt;/li&gt;

  &lt;li&gt;New feature - Added ExpandoObjectConverter that deserializes to primitive values rather than LINQ to JSON objects for ExpandObjects&lt;/li&gt;

  &lt;li&gt;New feature - Added EnumMemberAttribute support to StringEnumConverter&lt;/li&gt;

  &lt;li&gt;New feature - Added CloseInput/CloseOutput to JsonReader/JsonWriter to control whether the underlying stream is closed. Default to true&lt;/li&gt;

  &lt;li&gt;Change - JValue ToString now calls ToString on the internal value&lt;/li&gt;

  &lt;li&gt;Change - NuGet spec file includes client profiles&lt;/li&gt;

  &lt;li&gt;Change - BsonReader/BsonWriter close the underlying stream by default when closed&lt;/li&gt;

  &lt;li&gt;Change - CamelCasePropertyNamesContractResolver updates dictionary and dynamic property names&lt;/li&gt;

  &lt;li&gt;Fix – DefaultValueHandling no longer includes a property when the default value is the same value but a different type&lt;/li&gt;

  &lt;li&gt;Fix – Objects created with paramatized constructors fixed to not set properties that aren&amp;#39;t in JSON&lt;/li&gt;

  &lt;li&gt;Fix – Fixed comments in JSON sometimes causing errors when deserializing&lt;/li&gt;

  &lt;li&gt;Fix – Error when reflecting over type that has multiple index properties inherited fixed&lt;/li&gt;

  &lt;li&gt;Fix – Error when reusing JsonSerializer with preserve references enabled fixed&lt;/li&gt;

  &lt;li&gt;Fix – Poor error message when dynamic type cannot be created during deserialization fixed&lt;/li&gt;

  &lt;li&gt;Fix – Error when setting a null value on a dynamic type during deserialization fixed&lt;/li&gt;

  &lt;li&gt;Fix – JsonTextReader.ReadAsDecimal not attempting to convert string values to decimal fixed&lt;/li&gt;

  &lt;li&gt;Fix – Duplicate type name within an assembly error fixed&lt;/li&gt;

  &lt;li&gt;Fix – Deserializing a DataTable property fixed&lt;/li&gt;

  &lt;li&gt;Fix – Code emit error when deserializing interfaces in certain situations fixed&lt;/li&gt;

  &lt;li&gt;Fix – Performance issues when deserializing with partial type names fixed&lt;/li&gt;

  &lt;li&gt;Fix – Deserializing some decimal values on classes with non-default constructors fixed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/"&gt;Json.NET CodePlex Project&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/releases/view/64935"&gt;Json.NET 4.0 Release 2 Download&lt;/a&gt;&lt;/strong&gt; – Json.NET source code, documentation and binaries&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://james.newtonking.com/aggbug.aspx?PostID=43800" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/jamesnewtonking/~4/NnyXk6_reK0" height="1" width="1"/&gt;</description><feedburner:origLink>http://james.newtonking.com/archive/2011/04/21/json-net-4-0-release-2-nuget-1-2-and-dynamic.aspx</feedburner:origLink></item><item><title>Json.NET 4.0 Release 1 – .NET 4 and Windows Phone support</title><link>http://feeds.newtonking.com/~r/jamesnewtonking/~3/PxUBp-ITqYA/json-net-4-0-release-1-net-4-and-windows-phone-support.aspx</link><pubDate>Tue, 04 Jan 2011 01:47:24 GMT</pubDate><guid isPermaLink="false">bce7ef4a-1ab4-4a64-ae34-bb54d1362c7e:34989</guid><dc:creator>James Newton-King</dc:creator><slash:comments>129</slash:comments><comments>http://james.newtonking.com/archive/2011/01/03/json-net-4-0-release-1-net-4-and-windows-phone-support.aspx#comments</comments><description>&lt;p&gt;By popular demand: Json.NET 4.0! This is the first Json.NET release to target .NET 4 and integrates the many new features added in the latest version of .NET. Behind the scenes Json.NET’s source code has been upgraded to VS2010.&lt;/p&gt;  &lt;p&gt;Other major changes in this release are two new builds and the removal of an existing build. Removed is Compact Framework. VS2010 no longer supports Compact Framework so 3.5 r8 will be its last release if you are targeting the Compact Framework. New on the other hand are builds for .NET 3.5 (the main build has been upgraded to .NET 4) and Windows Phone.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Windows Phone dll&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;Json.NET 4.0 comes with a Windows Phone specific dll, compiled using the Windows Phone tools. The Silverlight build now targets Silverlight 4 so is no longer compatible with Windows Phone. A couple of little bonuses of Windows Phone having its own dll is that it doesn’t prompt with a warning when added. There is also some additional XML support. Because LINQ to XML is included in Windows Phone by default (it is an add-on dll for Silverlight) the Json.NET Windows Phone build has some XML features that are missing out of Silverlight release.&lt;/p&gt;  &lt;p&gt;&lt;strong&gt;Dynamic&lt;/strong&gt;&lt;/p&gt;  &lt;p&gt;One of the more interesting features introduced in .NET 4 is the dynamic keyword. Succinctly it allows variables and members to be statically typed as dynamic. The .NET type system that you know and love remains but operations involving dynamic values are evaluated at runtime.&lt;/p&gt;  &lt;p&gt;Json.NET 4.0 adds support for dynamic in a couple of areas. The first and less visible of the two is in the JsonSerializer. Because there is no static list of fields or properties for a dynamic type the serializer interrogates the value for its members prior to serializing and deserializing. The end result is serializing should Just Work for any type that implements IDynamicMetaObjectProvider.&lt;/p&gt;  &lt;div class="overflowpanel"&gt;   &lt;div class="code"&gt;     &lt;div style="font-family:courier new;color:black;font-size:10pt;"&gt;       &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;dynamic&lt;/span&gt; value = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;DynamicDictionary&lt;/span&gt;();&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;value.Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Arine Admin&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;value.Enabled = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;value.Roles = &lt;span style="color:blue;"&gt;new&lt;/span&gt;[] {&lt;span style="color:#a31515;"&gt;&amp;quot;Admin&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;User&amp;quot;&lt;/span&gt;};&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; json = &lt;span style="color:#2b91af;"&gt;JsonConvert&lt;/span&gt;.SerializeObject(value, &lt;span style="color:#2b91af;"&gt;Formatting&lt;/span&gt;.Indented);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// {&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;Name&amp;quot;: &amp;quot;Arine Admin&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;Enabled&amp;quot;: true,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; &amp;quot;Roles&amp;quot;: [&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;Admin&amp;quot;,&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160;&amp;#160;&amp;#160; &amp;quot;User&amp;quot;&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;//&amp;#160;&amp;#160; ]&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// }&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;dynamic&lt;/span&gt; newValue = &lt;span style="color:#2b91af;"&gt;JsonConvert&lt;/span&gt;.DeserializeObject&amp;lt;&lt;span style="color:#2b91af;"&gt;DynamicDictionary&lt;/span&gt;&amp;gt;(json);&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; role = newValue.Roles[0];&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// Admin&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;The second area with new dynamic support is LINQ to JSON. JObject properties can be accessed like that were members on a type and JValues can be converted to .NET types without casting, saving you the consumer precious KLOCs.&lt;/p&gt;

&lt;div class="overflowpanel"&gt;
  &lt;div class="code"&gt;
    &lt;div style="font-family:courier new;color:black;font-size:10pt;"&gt;
      &lt;pre style="margin:0px;"&gt;&lt;span style="color:#2b91af;"&gt;JObject&lt;/span&gt; oldAndBusted = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JObject&lt;/span&gt;();&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;oldAndBusted[&lt;span style="color:#a31515;"&gt;&amp;quot;Name&amp;quot;&lt;/span&gt;] = &lt;span style="color:#a31515;"&gt;&amp;quot;Arnie Admin&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;oldAndBusted[&lt;span style="color:#a31515;"&gt;&amp;quot;Enabled&amp;quot;&lt;/span&gt;] = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;oldAndBusted[&lt;span style="color:#a31515;"&gt;&amp;quot;Roles&amp;quot;&lt;/span&gt;] = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JArray&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt;[] { &lt;span style="color:#a31515;"&gt;&amp;quot;Admin&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;User&amp;quot;&lt;/span&gt; });&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; oldRole = (&lt;span style="color:blue;"&gt;string&lt;/span&gt;) oldAndBusted[&lt;span style="color:#a31515;"&gt;&amp;quot;Roles&amp;quot;&lt;/span&gt;][0];&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// Admin&lt;/span&gt;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;dynamic&lt;/span&gt; newHotness = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JObject&lt;/span&gt;();&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;newHotness.Name = &lt;span style="color:#a31515;"&gt;&amp;quot;Arnie Admin&amp;quot;&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;newHotness.Enabled = &lt;span style="color:blue;"&gt;true&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;newHotness.Roles = &lt;span style="color:blue;"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af;"&gt;JArray&lt;/span&gt;(&lt;span style="color:blue;"&gt;new&lt;/span&gt;[] { &lt;span style="color:#a31515;"&gt;&amp;quot;Admin&amp;quot;&lt;/span&gt;, &lt;span style="color:#a31515;"&gt;&amp;quot;User&amp;quot;&lt;/span&gt; });&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:blue;"&gt;string&lt;/span&gt; newRole = newHotness.Roles[0];&lt;/pre&gt;

      &lt;pre style="margin:0px;"&gt;&lt;span style="color:green;"&gt;// Admin&lt;/span&gt;&lt;/pre&gt;
    &lt;/div&gt;
  &lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;NuGet&lt;/p&gt;

&lt;p&gt;Json.NET has a &lt;a href="http://nuget.codeplex.com/" target="_blank"&gt;NuGet&lt;/a&gt; package available from the official NuGet package source. Right now it has Json.NET 3.5 Release 8 but expect it to be updated to Json.NET 4.0 in a couple of days.&lt;/p&gt;

&lt;p&gt;&lt;img style="background-image:none;border-right-width:0px;padding-left:0px;padding-right:0px;display:inline;border-top-width:0px;border-bottom-width:0px;border-left-width:0px;padding-top:0px;" title="I&amp;#39;m disrespectful to dirt! Can you see that I am serious? Out of my way, all of you! This is no place for loafers! Join me or die! Can you do any less?" border="0" alt="I&amp;#39;m disrespectful to dirt! Can you see that I am serious? Out of my way, all of you! This is no place for loafers! Join me or die! Can you do any less?" src="http://james.newtonking.com/images/Json.NET-4.0-Release-1--3.5-Final_80BB/jsonnetnuget.png" width="640" height="429" /&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JSON Schema&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Json.NET’s &lt;a href="http://json-schema.org/" target="_blank"&gt;JSON Schema&lt;/a&gt; implementation has been updated to match version 3 of the specification. Notable new additions are patternProperties, exclusiveMinimum and exclusiveMaximum. Also new is the removal of optional which has been replaced with required. If you are using JSON Schema then you should check whether this change effects your schemas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;BSON Binary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;a href="http://bsonspec.org/" target="_blank"&gt;BSON spec&lt;/a&gt; has changed how binary values inside BSON should be written, deprecating the way Json.NET use to write binary values. Json.NET has been changed to use the new method.&lt;/p&gt;

&lt;p&gt;Also worth noting is Json.NET had a bug with how it use to read and write the old binary values – this is fixed in Json.NET 4.0 but existing incorrect binary values will remain. Setting JsonNet35BinaryCompatibility on BsonReader will fix reading any existing BSON after upgrading to 4.0 but because of this bug and the change in how the spec says BSON binary values should be written it is recommended to update existing BSON to keep things consistent. This can be done by setting compatibility flag to true, reading BSON and then writing it back out again.&lt;/p&gt;

&lt;p&gt;These changes only effect BSON that has binary values (i.e. byte arrays) written inside BSON.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Changes&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is a complete list of what has changed since Json.NET 3.5 Release 8.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;New feature - Added Windows Phone 7 project &lt;/li&gt;

  &lt;li&gt;New feature - Added dynamic support to LINQ to JSON &lt;/li&gt;

  &lt;li&gt;New feature - Added dynamic support to serializer &lt;/li&gt;

  &lt;li&gt;New feature - Added INotifyCollectionChanged to JContainer in .NET 4 build &lt;/li&gt;

  &lt;li&gt;New feature - Added ReadAsDateTimeOffset to JsonReader &lt;/li&gt;

  &lt;li&gt;New feature - Added ReadAsDecimal to JsonReader &lt;/li&gt;

  &lt;li&gt;New feature - Added covariance to IJEnumerable type parameter &lt;/li&gt;

  &lt;li&gt;New feature - Added XmlSerializer style Specified property support &lt;/li&gt;

  &lt;li&gt;New feature - Added support for deserializing to JToken &lt;/li&gt;

  &lt;li&gt;New feature - Added CamelCaseText flag to StringEnumConverter &lt;/li&gt;

  &lt;li&gt;New feature - Added WriteArrayAttribute to XmlNodeConverter to include an attribute to help round tripping JSON and XML &lt;/li&gt;

  &lt;li&gt;New feature - Added OmitRootObject to XmlNodeConverter to skip writing the root JSON object when converting XML &lt;/li&gt;

  &lt;li&gt;New feature - Added DeepClone and ICloneable implementation to JToken &lt;/li&gt;

  &lt;li&gt;New feature - Added JSON schema PatternProperties, ExclusiveMinimum and ExclusiveMaximum for JSON schema spec 3 &lt;/li&gt;

  &lt;li&gt;New feature - Added .NET 3.5 project &lt;/li&gt;

  &lt;li&gt;Change - Updated source code to VS2010 &lt;/li&gt;

  &lt;li&gt;Change - Updated main project to .NET 4 &lt;/li&gt;

  &lt;li&gt;Change – Updated Silverlight project to Silverlight 4 &lt;/li&gt;

  &lt;li&gt;Change - ICustomTypeDescriptor implementation moved to JObject &lt;/li&gt;

  &lt;li&gt;Change - Improved error message when converting JSON with an empty property to XML &lt;/li&gt;

  &lt;li&gt;Change - JSON schema Required replaced with Optional, as defined in JSON schema spec 3 &lt;/li&gt;

  &lt;li&gt;Change - JSON schema MaxDecimals replaced with DivisibleBy, as defined in JSON schema spec 3 &lt;/li&gt;

  &lt;li&gt;Remove - Compact Framework project removed. Compact Framework is not supported in VS2010 &lt;/li&gt;

  &lt;li&gt;Remove - JTypeDescriptionProvider and JTypeDesciptor removed &lt;/li&gt;

  &lt;li&gt;Fix - BSON writing of binary values fixed. Added JsonNet35BinaryCompatibility flag for reading existing incorrect BSON binary values &lt;/li&gt;

  &lt;li&gt;Fix - Timezone information no longer lost when deserializing DateTimeOffsets &lt;/li&gt;

  &lt;li&gt;Fix – Decimal precision no longer lost when deserializing decimals &lt;/li&gt;

  &lt;li&gt;Fix - SelectToken no longer skips the last project name when it is a single character &lt;/li&gt;

  &lt;li&gt;Fix – Deserializing structs correctly set when reusing existing values is true &lt;/li&gt;

  &lt;li&gt;Fix – Private getter/setters on base classes are now correctly accessible &lt;/li&gt;

  &lt;li&gt;Fix – Nullable structs correctly deserialize &lt;/li&gt;

  &lt;li&gt;Fix - JSON Schema option label now written correctly &lt;/li&gt;

  &lt;li&gt;Fix – Deserializing a DataSet when it is a property of another object no longer breaks &lt;/li&gt;

  &lt;li&gt;Fix - JToken Load and Parse methods now check that content is complete &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Links&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/" target="_blank"&gt;Json.NET CodePlex Project&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;a href="http://json.codeplex.com/releases/view/58535" target="_blank"&gt;Json.NET 4.0 Release 1 Download&lt;/a&gt;&lt;/strong&gt; – Json.NET source code, documentation and binaries&lt;/p&gt;

&lt;p&gt;&lt;a href="http://www.dotnetkicks.com/kick/?url=http%3a%2f%2fjames.newtonking.com%2farchive%2f2011%2f01%2f03%2fjson-net-4-0-release-1-net-4-and-windows-phone-support.aspx"&gt;&lt;img src="http://dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url=http://james.newtonking.com/archive/2010/02/07/json-net-4-0-release-1-net-4-and-windows-phone-support.aspx" border="0" alt="kick it on DotNetKicks.com" /&gt;&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://james.newtonking.com/aggbug.aspx?PostID=34989" width="1" height="1"&gt;&lt;img src="http://feeds.feedburner.com/~r/jamesnewtonking/~4/PxUBp-ITqYA" height="1" width="1"/&gt;</description><feedburner:origLink>http://james.newtonking.com/archive/2011/01/03/json-net-4-0-release-1-net-4-and-windows-phone-support.aspx</feedburner:origLink></item></channel></rss>

