-Added IgnoreAll to DefaultValueHandling which ignores all default class/struct/privative values

-Added support for DataMemberAttribute's EmitDefaultValue
-Fixed losing decimal precision when writing JValues
-Fixed error when calling ToList on empty JObjects and JArrays
This commit is contained in:
James Newton-King
2012-09-01 13:34:07 +12:00
parent 028c287cff
commit d9c8d78d77
20 changed files with 312 additions and 39 deletions
+11 -6
View File
@@ -31,11 +31,11 @@
<para>Convert JSON to and from XML</para>
</listItem>
<listItem>
<para>Supports .NET 2, .NET 3.5, .NET 4, Silverlight, Windows Phone and Windows 8</para>
<para>Supports .NET 2, .NET 3.5, .NET 4, .NET 4.5, Silverlight, Windows Phone and Windows 8 RT</para>
</listItem>
</list>
<para>The JSON serializer is a good choice when the JSON you are reading or writing maps closely to a .NET class.</para>
<para>The JSON serializer in Json.NET is a good choice when the JSON you are reading or writing maps closely to a .NET class.</para>
<para>LINQ to JSON is good for situations where you are only interested in
getting values from JSON, you don't have a class to serialize or deserialize to,
or the JSON is radically different from your class and you need to manually read
@@ -72,19 +72,24 @@ and write from your objects.</para>
was required and Json.NET will split into the three major classes it still uses
today, JsonReader, JsonWriter and JsonSerializer.</para>
<para>Json.NET was first released in June 2006. Since then Json.NET has been downloaded
hundreds of thousands of times by developers and is used in a number of major open
hundreds of thousands of times by developers around the world. It is used in many major open
source projects including <externalLink>
<linkText>Mono</linkText>
<linkUri>http://www.mono-project.com/</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>,
an open source implementation
of the .NET framework, <externalLink>
of the .NET framework; <externalLink>
<linkText>RavenDB</linkText>
<linkUri>http://ravendb.net/</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>,
a JSON based documentat database, and <externalLink>
a JSON based documentat database; <externalLink>
<linkText>SignalR</linkText>
<linkUri>http://signalr.net/</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>,
an async library for building real-time, multi-user interactive web applications; and <externalLink>
<linkText>ASP.NET Web API</linkText>
<linkUri>http://www.asp.net/web-api</linkUri>
<linkTarget>_blank</linkTarget>
@@ -101,7 +106,7 @@ and write from your objects.</para>
<section>
<title>Donate</title>
<content><para>Json.NET is a free open source project developed in my own time.</para>
<para>I really appreciate your feedback and support for Json.NET and its future development.</para></content>
<para>I really appreciate your feedback and donations help support Json.NET and its future development.</para></content>
</section>
<markup>
+2 -2
View File
@@ -84,10 +84,10 @@
<content>
<para><codeEntityReference>T:Newtonsoft.Json.DefaultValueHandling</codeEntityReference>
is an option on the JsonSerializer and controls how the serializer handles
properties with a default value. Setting a value of DefaultValueHandling.Ignore
properties with a default value. Setting a value of DefaultValueHandling.IgnoreAll
will make the JsonSerializer skip writing any properties that have a default
value to the JSON result. For object references this will be null. For value
types like int and DateTime the serializer will skip the default unitialized
types like int and DateTime the serializer will skip the default uninitialized
value for that value type.</para>
<para>Json.NET also allows you to customize what the default value of an individual
+9 -2
View File
@@ -125,11 +125,18 @@
</tableHeader>
<row>
<entry><para><legacyBold>Include</legacyBold></para></entry>
<entry><para>By default Json.NET will write a field/property value to JSON when serializing if the value is the same as the field/property's default value. The Json.NET deserializer will continue setting a field/property if the JSON value is the same as the default value.</para></entry>
<entry><para>By default Json.NET will write a field/property value to JSON when serializing if the value is the same as the field/property's default value.
The Json.NET deserializer will continue setting a field/property if the JSON value is the same as the default value.</para></entry>
</row>
<row>
<entry><para><legacyBold>Ignore</legacyBold></para></entry>
<entry><para>Json.NET will skip writing a field/property value to JSON if the value is the same as the field/property's default value. The Json.NET deserializer will skip setting a .NET object's field/property if the JSON value is the same as the default value.</para></entry>
<entry><para>Json.NET will skip writing a field/property value to JSON if the value is null or is the same as the value specified in field/property's <codeEntityReference>T:System.ComponentModel.DefaultValueAttribute</codeEntityReference>. The Json.NET deserializer will skip setting a .NET object's field/property if the JSON value is the same as the default value.</para></entry>
</row>
<row>
<entry><para><legacyBold>IgnoreAll</legacyBold></para></entry>
<entry><para>Json.NET will skip writing a field/property value to JSON if the value is the same as the field/property's default value, or the custom
value specified in <codeEntityReference>T:System.ComponentModel.DefaultValueAttribute</codeEntityReference> if it is present. The Json.NET deserializer
will skip setting a .NET object's field/property if the JSON value is the same as the default value.</para></entry>
</row>
</table>
<para>DefaultValueHandling can also be customized on individual properties with JsonPropertyAttribute.</para>
-1
View File
@@ -141,7 +141,6 @@
<None Include="ContractResolver.aml" />
<None Include="ConvertingJSONandXML.aml" />
<None Include="CreatingLINQtoJSON.aml" />
<None Include="Copy of ContractResolver.aml" />
<None Include="JsonSchema.aml" />
<None Include="JsonSchema.aml" />
<None Include="ParsingLINQtoJSON.aml" />