-Documentation
-Performance
This commit is contained in:
@@ -0,0 +1,454 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonNetVsDotNetSerializers" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>Json.NET offers many features not found in the JavaScriptSerializer and DataContractSerializer that come with .NET.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Feature Comparison</title>
|
||||||
|
<content>
|
||||||
|
<table>
|
||||||
|
<tableHeader>
|
||||||
|
<row>
|
||||||
|
<entry><para></para></entry>
|
||||||
|
<entry><para>Json.NET</para></entry>
|
||||||
|
<entry><para>DataContractJsonSerializer</para></entry>
|
||||||
|
<entry><para>JavaScriptSerializer</para></entry>
|
||||||
|
</row>
|
||||||
|
</tableHeader>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports JSON</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports BSON</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports JSON Schema</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports .NET 2.0</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports .NET 3.5</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports .NET 4.0</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports Silverlight</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports Windows Phone</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports WinRT</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Open Source</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>MIT License</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>LINQ to JSON</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Thread Safe</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>XPath-like JSON query syntax</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Indented JSON support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>
|
||||||
|
<externalLink>
|
||||||
|
<linkText>Efficient dictionary serialization</linkText>
|
||||||
|
<linkUri>http://stackoverflow.com/questions/1207731/how-can-i-deserialize-json-to-a-simple-dictionarystring-string-in-asp-net</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink>
|
||||||
|
</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>
|
||||||
|
<externalLink>
|
||||||
|
<linkText>Nonsensical dictionary serialization</linkText>
|
||||||
|
<linkUri>http://stackoverflow.com/questions/4559991/any-way-to-make-datacontractjsonserializer-serialize-dictionaries-properly</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink>
|
||||||
|
</para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Deserializes IList, IEnumerable, ICollection, IDictionary properties</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes circular references</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports serializing objects by reference</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Deserializes polymorphic properties and collections</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes and deserializes multidimensional arrays</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports including type names with JSON</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Globally customize serialization process</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports excluding null values when serializing</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports SerializationBinder</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Conditional property serialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Includes line number information in errors</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Converts XML to JSON and JSON to XML</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>JSON Schema validation</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>JSON Schema generation from .NET types</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Camel case JSON property names</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Non-default constructors support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serialization error handling</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports populating an existing object</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Efficiently serializes byte arrays as base64 text</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Handles NaN, Infinity, -Infinity and undefined</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Handles JavaScript constructors</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes .NET 4.0 dynamic objects</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes ISerializable objects</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports serializing enums to their text name</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>JSON recursion limit support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Attribute property name customization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Attribute property order customization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Attribute property required customization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports ISO8601 dates</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports JavaScript constructor dates</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports Microsoft AJAX dates</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Unquoted property names support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Raw JSON support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports reading and writing comments</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes anonymous types</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Deserializes anonymous types</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Opt-in mode serialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Opt-out mode serialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Field (Serializable) mode serialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Efficiently stream reading and writing JSON</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Single or double quote JSON content</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports overriding a type's serialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports OnDeserialized, OnSerializing, OnSerialized and OnDeserializing attributes</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Supports serializing private properties</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>DataMember attribute support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>MetdataType attribute support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>DefaultValue attribute support</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes DataSets and DataTables</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serailizes Entity Framework</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Serializes nHibernate</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry><para>Case-insensitive property deserialization</para></entry>
|
||||||
|
<entry><para><markup><img src="../tick.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
<entry><para><markup><img src="../cross.png" /></markup></para></entry>
|
||||||
|
</row>
|
||||||
|
</table>
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>Benchmarks</title>
|
||||||
|
<content>
|
||||||
|
|
||||||
|
<mediaLink>
|
||||||
|
<image class="image" xlink:href="performance" mimeType="image/png" width="643" height="345" />
|
||||||
|
<summary>Json.NET Performance</summary>
|
||||||
|
</mediaLink>
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
@@ -0,0 +1,101 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<topic id="JsonNetVsWindowsDataJson" revisionNumber="1">
|
||||||
|
<developerConceptualDocument xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||||
|
<introduction>
|
||||||
|
<para>Windows 8 introduces a new way to work with JSON via the <externalLink>
|
||||||
|
<linkText>Windows.Data.Json</linkText>
|
||||||
|
<linkUri>http://msdn.microsoft.com/en-us/library/windows/apps/xaml/br240639.aspx</linkUri>
|
||||||
|
<linkTarget>_blank</linkTarget>
|
||||||
|
</externalLink> namespace. Similar to LINQ to JSON in Json.NET
|
||||||
|
it defines classes that can be used to parse values, strings, objects, and arrays from
|
||||||
|
JSON text or serialize value types into JSON text.</para>
|
||||||
|
<para>Below is a comparison of Json.NET's LINQ to JSON to Window 8's Windows.Data.Json.</para>
|
||||||
|
</introduction>
|
||||||
|
<section>
|
||||||
|
<title>Exclusive Json.NET Features</title>
|
||||||
|
<content>
|
||||||
|
<list class="bullet">
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Runs on .NET 2, .NET 3, .NET 4, Silverlight and Windows Phone 7
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Supports dynamic programming
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Write indented JSON
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Customize reading and writing JSON with JsonConverters
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Read and write ISO8601 dates
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
<listItem>
|
||||||
|
<para>
|
||||||
|
Better LINQ support
|
||||||
|
</para>
|
||||||
|
</listItem>
|
||||||
|
</list>
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>Creating JSON</title>
|
||||||
|
<content>
|
||||||
|
<para>The big difference between the two libraries when creating JSON is Windows.Data.Json requires
|
||||||
|
string/integer/double values to be explicitly converted to JsonValue objects.</para>
|
||||||
|
<para>Note that there is a weird limitation to creating JSON with Windows.Data.Json: it doesn't
|
||||||
|
allow you to set properties to null or put null values in an array.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonNetVsWindowsDataJsonTests.cs" region="CreatingJSON" title="Creating JSON with Json.NET and Windows.Data.Json" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>Querying JSON</title>
|
||||||
|
<content>
|
||||||
|
<para>Windows.Data.Json requires a value to be cast to its exact type with the GetObject/GetArray methods
|
||||||
|
before it can be used, making Windows.Data.Json's code verbose compared to LINQ to JSON.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonNetVsWindowsDataJsonTests.cs" region="QueryingJSON" title="Querying JSON with Json.NET and Windows.Data.Json" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>Performance</title>
|
||||||
|
<content>
|
||||||
|
<para>Json.NET is slightly slower at writing JSON than Windows.Data.Json but considerably faster at parsing JSON.</para>
|
||||||
|
|
||||||
|
<mediaLink>
|
||||||
|
<image class="image" xlink:href="jsonnetwindowsdatajson" mimeType="image/png" width="592" height="356" />
|
||||||
|
<summary>Json.NET and Windows.Data.Json Performance</summary>
|
||||||
|
</mediaLink>
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<section>
|
||||||
|
<title>Converting Between LINQ to JSON and Windows.Data.Json</title>
|
||||||
|
<content>
|
||||||
|
<para>Json.NET supports converting between the types of the two libraries.
|
||||||
|
This feature is useful if you are working with another API but you want to use Json.NET inside your own code.</para>
|
||||||
|
<para>Use <codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.FromObject</codeEntityReference> to convert a Windows.Data.Json
|
||||||
|
value to LINQ to JSON and use <codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.ToObject</codeEntityReference> to convert LINQ to JSON to Windows.Data.Json.</para>
|
||||||
|
|
||||||
|
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\JsonNetVsWindowsDataJsonTests.cs" region="Converting" title="Converting between Json.NET and Windows.Data.Json" />
|
||||||
|
|
||||||
|
</content>
|
||||||
|
</section>
|
||||||
|
<relatedTopics>
|
||||||
|
<codeEntityReference>N:Newtonsoft.Json.Linq</codeEntityReference>
|
||||||
|
</relatedTopics>
|
||||||
|
</developerConceptualDocument>
|
||||||
|
</topic>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 655 B |
+4
-2
@@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Topics>
|
<Topics>
|
||||||
<Topic id="Introduction" visible="True" isDefault="true" />
|
<Topic id="Introduction" visible="True" isDefault="true" />
|
||||||
<Topic id="SerializingJSON" visible="True" isExpanded="true" title="Serializing and Deserializing JSON">
|
<Topic id="SerializingJSON" visible="True" title="Serializing and Deserializing JSON">
|
||||||
<Topic id="SerializationSettings" visible="True" title="Serialization Settings" />
|
<Topic id="SerializationSettings" visible="True" title="Serialization Settings" />
|
||||||
<Topic id="SerializationGuide" visible="True" title="Serialization Guide" />
|
<Topic id="SerializationGuide" visible="True" title="Serialization Guide" />
|
||||||
<Topic id="SerializationAttributes" visible="True" title="Serialization Attributes" />
|
<Topic id="SerializationAttributes" visible="True" title="Serialization Attributes" />
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<Topic id="ReducingSerializedJSONSize" visible="True" title="Reducing Serialized JSON Size" />
|
<Topic id="ReducingSerializedJSONSize" visible="True" title="Reducing Serialized JSON Size" />
|
||||||
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
<Topic id="SerializingJSONFragments" visible="True" title="Serializing Partial JSON Fragments" />
|
||||||
<Topic id="ConditionalProperties" visible="True" title="Conditional Properties" />
|
<Topic id="ConditionalProperties" visible="True" title="Conditional Properties" />
|
||||||
<Topic id="ContractResolver" visible="True" isSelected="true" title="Serialization using ContractResolver" />
|
<Topic id="ContractResolver" visible="True" title="Serialization using ContractResolver" />
|
||||||
</Topic>
|
</Topic>
|
||||||
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
<Topic id="LINQtoJSON" visible="True" title="LINQ to JSON">
|
||||||
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
<Topic id="ParsingLINQtoJSON" visible="True" title="Parsing JSON" />
|
||||||
@@ -26,4 +26,6 @@
|
|||||||
<Topic id="JsonSchema" visible="True" title="Validating JSON" />
|
<Topic id="JsonSchema" visible="True" title="Validating JSON" />
|
||||||
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
|
<Topic id="ReadingWritingJSON" visible="True" title="Basic Reading and Writing JSON" />
|
||||||
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
<Topic id="ConvertingJSONandXML" visible="True" title="Converting between JSON and XML" />
|
||||||
|
<Topic id="JsonNetVsWindowsDataJson" visible="True" title="Json.NET vs Windows.Data.Json" />
|
||||||
|
<Topic id="JsonNetVsDotNetSerializers" visible="True" isSelected="true" title="Json.NET vs .NET Serializers" />
|
||||||
</Topics>
|
</Topics>
|
||||||
@@ -137,6 +137,8 @@
|
|||||||
<Content Include="donate.gif" />
|
<Content Include="donate.gif" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<None Include="JsonNetVsDotNetSerializers.aml" />
|
||||||
|
<None Include="JsonNetVsWindowsDataJson.aml" />
|
||||||
<None Include="ConditionalProperties.aml" />
|
<None Include="ConditionalProperties.aml" />
|
||||||
<None Include="CustomCreationConverter.aml" />
|
<None Include="CustomCreationConverter.aml" />
|
||||||
<None Include="ContractResolver.aml" />
|
<None Include="ContractResolver.aml" />
|
||||||
@@ -167,6 +169,18 @@
|
|||||||
<ContentLayout Include="doc.content" />
|
<ContentLayout Include="doc.content" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Content Include="tick.png">
|
||||||
|
<ImageId>tick</ImageId>
|
||||||
|
<AlternateText>tick</AlternateText>
|
||||||
|
</Content>
|
||||||
|
<Content Include="cross.png">
|
||||||
|
<ImageId>cross</ImageId>
|
||||||
|
<AlternateText>cross</AlternateText>
|
||||||
|
</Content>
|
||||||
|
<Image Include="jsonnetwindowsdatajson.png">
|
||||||
|
<ImageId>jsonnetwindowsdatajson</ImageId>
|
||||||
|
<AlternateText>jsonnetwindowsdatajson</AlternateText>
|
||||||
|
</Image>
|
||||||
<Image Include="performance.png">
|
<Image Include="performance.png">
|
||||||
<ImageId>performance</ImageId>
|
<ImageId>performance</ImageId>
|
||||||
<AlternateText>performance</AlternateText>
|
<AlternateText>performance</AlternateText>
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 6.4 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 537 B |
@@ -0,0 +1,108 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
namespace Newtonsoft.Json.Tests.Documentation
|
||||||
|
{
|
||||||
|
public class JsonNetVsWindowsDataJsonTests
|
||||||
|
{
|
||||||
|
public void CreatingJson()
|
||||||
|
{
|
||||||
|
#if NETFX_CORE
|
||||||
|
#region CreatingJSON
|
||||||
|
// Windows.Data.Json
|
||||||
|
// -----------------
|
||||||
|
JsonObject jsonObject = new JsonObject
|
||||||
|
{
|
||||||
|
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||||
|
{
|
||||||
|
"Drives", new JsonArray
|
||||||
|
{
|
||||||
|
JsonValue.CreateStringValue("DVD read/writer"),
|
||||||
|
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
string json1 = jsonObject.Stringify();
|
||||||
|
|
||||||
|
// LINQ to JSON
|
||||||
|
// ------------
|
||||||
|
JObject jObject = new JObject
|
||||||
|
{
|
||||||
|
{"CPU", "Intel"},
|
||||||
|
{
|
||||||
|
"Drives", new JArray
|
||||||
|
{
|
||||||
|
"DVD read/writer",
|
||||||
|
"500 gigabyte hard drive"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
string json2 = jObject.ToString();
|
||||||
|
#endregion
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void QueryingJson()
|
||||||
|
{
|
||||||
|
#if NETFX_CORE
|
||||||
|
#region QueryingJSON
|
||||||
|
string json = @"{
|
||||||
|
'channel': {
|
||||||
|
'title': 'James Newton-King',
|
||||||
|
'link': 'http://james.newtonking.com',
|
||||||
|
'description': 'James Newton-King's blog.',
|
||||||
|
'item': [
|
||||||
|
{
|
||||||
|
'title': 'Json.NET 1.3 + New license + Now on CodePlex',
|
||||||
|
'description': 'Annoucing the release of Json.NET 1.3, the MIT license and the source being available on CodePlex',
|
||||||
|
'link': 'http://james.newtonking.com/projects/json-net.aspx',
|
||||||
|
'category': [
|
||||||
|
'Json.NET',
|
||||||
|
'CodePlex'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}";
|
||||||
|
|
||||||
|
// Windows.Data.Json
|
||||||
|
// -----------------
|
||||||
|
JsonObject jsonObject = JsonObject.Parse(json);
|
||||||
|
string itemTitle1 = jsonObject["channel"].GetObject()["item"].GetArray()[0].GetObject()["title"].GetString();
|
||||||
|
|
||||||
|
// LINQ to JSON
|
||||||
|
// ------------
|
||||||
|
JObject jObject = JObject.Parse(json);
|
||||||
|
string itemTitle2 = (string)jObject["channel"]["item"][0]["title"];
|
||||||
|
#endregion
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Converting()
|
||||||
|
{
|
||||||
|
#if NETFX_CORE
|
||||||
|
#region Converting
|
||||||
|
JsonObject jsonObject = new JsonObject
|
||||||
|
{
|
||||||
|
{"CPU", JsonValue.CreateStringValue("Intel")},
|
||||||
|
{"Drives", new JsonArray {
|
||||||
|
JsonValue.CreateStringValue("DVD read/writer"),
|
||||||
|
JsonValue.CreateStringValue("500 gigabyte hard drive")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// convert Windows.Data.Json to LINQ to JSON
|
||||||
|
JObject o = JObject.FromObject(jsonObject);
|
||||||
|
|
||||||
|
// convert LINQ to JSON to Windows.Data.Json
|
||||||
|
JArray a = (JArray)o["Drives"];
|
||||||
|
JsonArray jsonArray = a.ToObject<JsonArray>();
|
||||||
|
#endregion
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -713,6 +713,7 @@ _____'propertyName': NaN
|
|||||||
jsonWriter.WriteValue(data);
|
jsonWriter.WriteValue(data);
|
||||||
jsonWriter.WriteValue((object)data);
|
jsonWriter.WriteValue((object)data);
|
||||||
jsonWriter.WriteValue((byte[])null);
|
jsonWriter.WriteValue((byte[])null);
|
||||||
|
jsonWriter.WriteValue((Uri)null);
|
||||||
jsonWriter.WriteEndArray();
|
jsonWriter.WriteEndArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -720,6 +721,7 @@ _____'propertyName': NaN
|
|||||||
""SGVsbG8gd29ybGQu"",
|
""SGVsbG8gd29ybGQu"",
|
||||||
""SGVsbG8gd29ybGQu"",
|
""SGVsbG8gd29ybGQu"",
|
||||||
""SGVsbG8gd29ybGQu"",
|
""SGVsbG8gd29ybGQu"",
|
||||||
|
null,
|
||||||
null
|
null
|
||||||
]";
|
]";
|
||||||
string result = sb.ToString();
|
string result = sb.ToString();
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ namespace Newtonsoft.Json.Tests
|
|||||||
[TestFixture]
|
[TestFixture]
|
||||||
public class PerformanceTests : TestFixtureBase
|
public class PerformanceTests : TestFixtureBase
|
||||||
{
|
{
|
||||||
private const int Iterations = 100;
|
//private const int Iterations = 100;
|
||||||
//private const int Iterations = 5000;
|
private const int Iterations = 5000;
|
||||||
|
|
||||||
#region Data
|
#region Data
|
||||||
|
|
||||||
@@ -122,21 +122,19 @@ namespace Newtonsoft.Json.Tests
|
|||||||
TestClass test = CreateSerializationObject();
|
TestClass test = CreateSerializationObject();
|
||||||
|
|
||||||
SerializeTests(test);
|
SerializeTests(test);
|
||||||
|
|
||||||
Deserialize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SerializeTests(object value)
|
private void SerializeTests(object value)
|
||||||
{
|
{
|
||||||
BenchmarkSerializeMethod(SerializeMethod.DataContractSerializer, value);
|
//BenchmarkSerializeMethod(SerializeMethod.DataContractSerializer, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.BinaryFormatter, value);
|
//BenchmarkSerializeMethod(SerializeMethod.BinaryFormatter, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JavaScriptSerializer, value);
|
//BenchmarkSerializeMethod(SerializeMethod.JavaScriptSerializer, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.DataContractJsonSerializer, value);
|
//BenchmarkSerializeMethod(SerializeMethod.DataContractJsonSerializer, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JsonNet, value);
|
//BenchmarkSerializeMethod(SerializeMethod.JsonNet, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JsonNetLinq, value);
|
//BenchmarkSerializeMethod(SerializeMethod.JsonNetLinq, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JsonNetManual, value);
|
BenchmarkSerializeMethod(SerializeMethod.JsonNetManual, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JsonNetWithIsoConverter, value);
|
//BenchmarkSerializeMethod(SerializeMethod.JsonNetWithIsoConverter, value);
|
||||||
BenchmarkSerializeMethod(SerializeMethod.JsonNetBinary, value);
|
//BenchmarkSerializeMethod(SerializeMethod.JsonNetBinary, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -76,5 +76,5 @@ using System.Security;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("4.5.10.15431")]
|
[assembly: AssemblyFileVersion("4.5.10.15501")]
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -148,7 +148,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WriteStartObject()
|
public override void WriteStartObject()
|
||||||
{
|
{
|
||||||
base.WriteStartObject();
|
InternalWriteStart(JsonToken.StartObject, JsonContainerType.Object);
|
||||||
|
|
||||||
_writer.Write("{");
|
_writer.Write("{");
|
||||||
}
|
}
|
||||||
@@ -158,7 +158,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WriteStartArray()
|
public override void WriteStartArray()
|
||||||
{
|
{
|
||||||
base.WriteStartArray();
|
InternalWriteStart(JsonToken.StartArray, JsonContainerType.Array);
|
||||||
|
|
||||||
_writer.Write("[");
|
_writer.Write("[");
|
||||||
}
|
}
|
||||||
@@ -169,7 +169,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="name">The name of the constructor.</param>
|
/// <param name="name">The name of the constructor.</param>
|
||||||
public override void WriteStartConstructor(string name)
|
public override void WriteStartConstructor(string name)
|
||||||
{
|
{
|
||||||
base.WriteStartConstructor(name);
|
InternalWriteStart(JsonToken.StartConstructor, JsonContainerType.Constructor);
|
||||||
|
|
||||||
_writer.Write("new ");
|
_writer.Write("new ");
|
||||||
_writer.Write(name);
|
_writer.Write(name);
|
||||||
@@ -204,7 +204,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="name">The name of the property.</param>
|
/// <param name="name">The name of the property.</param>
|
||||||
public override void WritePropertyName(string name)
|
public override void WritePropertyName(string name)
|
||||||
{
|
{
|
||||||
base.WritePropertyName(name);
|
InternalWritePropertyName(name);
|
||||||
|
|
||||||
JavaScriptUtils.WriteEscapedJavaScriptString(_writer, name, _quoteChar, _quoteName);
|
JavaScriptUtils.WriteEscapedJavaScriptString(_writer, name, _quoteChar, _quoteName);
|
||||||
|
|
||||||
@@ -259,7 +259,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WriteNull()
|
public override void WriteNull()
|
||||||
{
|
{
|
||||||
base.WriteNull();
|
InternalWriteNull();
|
||||||
WriteValueInternal(JsonConvert.Null, JsonToken.Null);
|
WriteValueInternal(JsonConvert.Null, JsonToken.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -268,7 +268,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void WriteUndefined()
|
public override void WriteUndefined()
|
||||||
{
|
{
|
||||||
base.WriteUndefined();
|
InternalWriteUndefined();
|
||||||
WriteValueInternal(JsonConvert.Undefined, JsonToken.Undefined);
|
WriteValueInternal(JsonConvert.Undefined, JsonToken.Undefined);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,7 +278,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="json">The raw JSON to write.</param>
|
/// <param name="json">The raw JSON to write.</param>
|
||||||
public override void WriteRaw(string json)
|
public override void WriteRaw(string json)
|
||||||
{
|
{
|
||||||
base.WriteRaw(json);
|
InternalWriteRaw();
|
||||||
|
|
||||||
_writer.Write(json);
|
_writer.Write(json);
|
||||||
}
|
}
|
||||||
@@ -289,7 +289,8 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="String"/> value to write.</param>
|
/// <param name="value">The <see cref="String"/> value to write.</param>
|
||||||
public override void WriteValue(string value)
|
public override void WriteValue(string value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.String);
|
||||||
|
|
||||||
if (value == null)
|
if (value == null)
|
||||||
WriteValueInternal(JsonConvert.Null, JsonToken.Null);
|
WriteValueInternal(JsonConvert.Null, JsonToken.Null);
|
||||||
else
|
else
|
||||||
@@ -302,7 +303,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int32"/> value to write.</param>
|
/// <param name="value">The <see cref="Int32"/> value to write.</param>
|
||||||
public override void WriteValue(int value)
|
public override void WriteValue(int value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +314,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public override void WriteValue(uint value)
|
public override void WriteValue(uint value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -323,7 +324,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int64"/> value to write.</param>
|
/// <param name="value">The <see cref="Int64"/> value to write.</param>
|
||||||
public override void WriteValue(long value)
|
public override void WriteValue(long value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -334,7 +335,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public override void WriteValue(ulong value)
|
public override void WriteValue(ulong value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -344,7 +345,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Single"/> value to write.</param>
|
/// <param name="value">The <see cref="Single"/> value to write.</param>
|
||||||
public override void WriteValue(float value)
|
public override void WriteValue(float value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Float);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -354,7 +355,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Double"/> value to write.</param>
|
/// <param name="value">The <see cref="Double"/> value to write.</param>
|
||||||
public override void WriteValue(double value)
|
public override void WriteValue(double value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Float);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -364,7 +365,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Boolean"/> value to write.</param>
|
/// <param name="value">The <see cref="Boolean"/> value to write.</param>
|
||||||
public override void WriteValue(bool value)
|
public override void WriteValue(bool value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Boolean);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Boolean);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +375,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int16"/> value to write.</param>
|
/// <param name="value">The <see cref="Int16"/> value to write.</param>
|
||||||
public override void WriteValue(short value)
|
public override void WriteValue(short value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -385,7 +386,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public override void WriteValue(ushort value)
|
public override void WriteValue(ushort value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,8 +396,8 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Char"/> value to write.</param>
|
/// <param name="value">The <see cref="Char"/> value to write.</param>
|
||||||
public override void WriteValue(char value)
|
public override void WriteValue(char value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.String);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -405,7 +406,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Byte"/> value to write.</param>
|
/// <param name="value">The <see cref="Byte"/> value to write.</param>
|
||||||
public override void WriteValue(byte value)
|
public override void WriteValue(byte value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +417,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public override void WriteValue(sbyte value)
|
public override void WriteValue(sbyte value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Integer);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Integer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -426,7 +427,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Decimal"/> value to write.</param>
|
/// <param name="value">The <see cref="Decimal"/> value to write.</param>
|
||||||
public override void WriteValue(decimal value)
|
public override void WriteValue(decimal value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Float);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.Float);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -436,7 +437,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
||||||
public override void WriteValue(DateTime value)
|
public override void WriteValue(DateTime value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Date);
|
||||||
value = JsonConvert.EnsureDateTime(value, DateTimeZoneHandling);
|
value = JsonConvert.EnsureDateTime(value, DateTimeZoneHandling);
|
||||||
JsonConvert.WriteDateTimeString(_writer, value, DateFormatHandling);
|
JsonConvert.WriteDateTimeString(_writer, value, DateFormatHandling);
|
||||||
}
|
}
|
||||||
@@ -447,10 +448,13 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="T:Byte[]"/> value to write.</param>
|
/// <param name="value">The <see cref="T:Byte[]"/> value to write.</param>
|
||||||
public override void WriteValue(byte[] value)
|
public override void WriteValue(byte[] value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
if (value == null)
|
||||||
|
|
||||||
if (value != null)
|
|
||||||
{
|
{
|
||||||
|
WriteNull();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InternalWriteValue(JsonToken.Bytes);
|
||||||
_writer.Write(_quoteChar);
|
_writer.Write(_quoteChar);
|
||||||
Base64Encoder.Encode(value, 0, value.Length);
|
Base64Encoder.Encode(value, 0, value.Length);
|
||||||
Base64Encoder.Flush();
|
Base64Encoder.Flush();
|
||||||
@@ -465,7 +469,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="DateTimeOffset"/> value to write.</param>
|
/// <param name="value">The <see cref="DateTimeOffset"/> value to write.</param>
|
||||||
public override void WriteValue(DateTimeOffset value)
|
public override void WriteValue(DateTimeOffset value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.Date);
|
||||||
WriteValueInternal(JsonConvert.ToString(value, DateFormatHandling), JsonToken.Date);
|
WriteValueInternal(JsonConvert.ToString(value, DateFormatHandling), JsonToken.Date);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -476,7 +480,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Guid"/> value to write.</param>
|
/// <param name="value">The <see cref="Guid"/> value to write.</param>
|
||||||
public override void WriteValue(Guid value)
|
public override void WriteValue(Guid value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.String);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -486,7 +490,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="TimeSpan"/> value to write.</param>
|
/// <param name="value">The <see cref="TimeSpan"/> value to write.</param>
|
||||||
public override void WriteValue(TimeSpan value)
|
public override void WriteValue(TimeSpan value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
InternalWriteValue(JsonToken.String);
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -496,8 +500,15 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Uri"/> value to write.</param>
|
/// <param name="value">The <see cref="Uri"/> value to write.</param>
|
||||||
public override void WriteValue(Uri value)
|
public override void WriteValue(Uri value)
|
||||||
{
|
{
|
||||||
base.WriteValue(value);
|
if (value == null)
|
||||||
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
{
|
||||||
|
WriteNull();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
InternalWriteValue(JsonToken.String);
|
||||||
|
WriteValueInternal(JsonConvert.ToString(value), JsonToken.String);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -507,7 +518,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="text">Text to place inside the comment.</param>
|
/// <param name="text">Text to place inside the comment.</param>
|
||||||
public override void WriteComment(string text)
|
public override void WriteComment(string text)
|
||||||
{
|
{
|
||||||
base.WriteComment(text);
|
InternalWriteComment();
|
||||||
|
|
||||||
_writer.Write("/*");
|
_writer.Write("/*");
|
||||||
_writer.Write(text);
|
_writer.Write(text);
|
||||||
@@ -520,7 +531,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="ws">The string of white space characters.</param>
|
/// <param name="ws">The string of white space characters.</param>
|
||||||
public override void WriteWhitespace(string ws)
|
public override void WriteWhitespace(string ws)
|
||||||
{
|
{
|
||||||
base.WriteWhitespace(ws);
|
InternalWriteWhitespace(ws);
|
||||||
|
|
||||||
_writer.Write(ws);
|
_writer.Write(ws);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ namespace Newtonsoft.Json
|
|||||||
Array,
|
Array,
|
||||||
ConstructorStart,
|
ConstructorStart,
|
||||||
Constructor,
|
Constructor,
|
||||||
Bytes,
|
|
||||||
Closed,
|
Closed,
|
||||||
Error
|
Error
|
||||||
}
|
}
|
||||||
@@ -69,7 +68,7 @@ namespace Newtonsoft.Json
|
|||||||
/* StartObject */new[]{ State.ObjectStart, State.ObjectStart, State.Error, State.Error, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.Error, State.Error },
|
/* StartObject */new[]{ State.ObjectStart, State.ObjectStart, State.Error, State.Error, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.ObjectStart, State.Error, State.Error },
|
||||||
/* StartArray */new[]{ State.ArrayStart, State.ArrayStart, State.Error, State.Error, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.Error, State.Error },
|
/* StartArray */new[]{ State.ArrayStart, State.ArrayStart, State.Error, State.Error, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.ArrayStart, State.Error, State.Error },
|
||||||
/* StartConstructor */new[]{ State.ConstructorStart, State.ConstructorStart, State.Error, State.Error, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.Error, State.Error },
|
/* StartConstructor */new[]{ State.ConstructorStart, State.ConstructorStart, State.Error, State.Error, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.ConstructorStart, State.Error, State.Error },
|
||||||
/* StartProperty */new[]{ State.Property, State.Error, State.Property, State.Property, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error },
|
/* Property */new[]{ State.Property, State.Error, State.Property, State.Property, State.Error, State.Error, State.Error, State.Error, State.Error, State.Error },
|
||||||
/* Comment */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
/* Comment */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
||||||
/* Raw */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
/* Raw */new[]{ State.Start, State.Property, State.ObjectStart, State.Object, State.ArrayStart, State.Array, State.Constructor, State.Constructor, State.Error, State.Error },
|
||||||
/* Value (this will be copied) */new[]{ State.Start, State.Object, State.Error, State.Error, State.Array, State.Array, State.Constructor, State.Constructor, State.Error, State.Error }
|
/* Value (this will be copied) */new[]{ State.Start, State.Object, State.Error, State.Error, State.Array, State.Array, State.Constructor, State.Constructor, State.Error, State.Error }
|
||||||
@@ -316,10 +315,15 @@ namespace Newtonsoft.Json
|
|||||||
/// Writes the beginning of a Json object.
|
/// Writes the beginning of a Json object.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteStartObject()
|
public virtual void WriteStartObject()
|
||||||
|
{
|
||||||
|
InternalWriteStart(JsonToken.StartObject, JsonContainerType.Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteStart(JsonToken token, JsonContainerType container)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
UpdateScopeWithFinishedValue();
|
||||||
AutoComplete(JsonToken.StartObject);
|
AutoComplete(token);
|
||||||
Push(JsonContainerType.Object);
|
Push(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -327,7 +331,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteEndObject()
|
public virtual void WriteEndObject()
|
||||||
{
|
{
|
||||||
AutoCompleteClose(JsonContainerType.Object);
|
InternalWriteEnd(JsonContainerType.Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -335,9 +339,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteStartArray()
|
public virtual void WriteStartArray()
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteStart(JsonToken.StartArray, JsonContainerType.Array);
|
||||||
AutoComplete(JsonToken.StartArray);
|
|
||||||
Push(JsonContainerType.Array);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -345,7 +347,7 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteEndArray()
|
public virtual void WriteEndArray()
|
||||||
{
|
{
|
||||||
AutoCompleteClose(JsonContainerType.Array);
|
InternalWriteEnd(JsonContainerType.Array);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -354,9 +356,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="name">The name of the constructor.</param>
|
/// <param name="name">The name of the constructor.</param>
|
||||||
public virtual void WriteStartConstructor(string name)
|
public virtual void WriteStartConstructor(string name)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteStart(JsonToken.StartConstructor, JsonContainerType.Constructor);
|
||||||
AutoComplete(JsonToken.StartConstructor);
|
|
||||||
Push(JsonContainerType.Constructor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -364,7 +364,12 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteEndConstructor()
|
public virtual void WriteEndConstructor()
|
||||||
{
|
{
|
||||||
AutoCompleteClose(JsonContainerType.Constructor);
|
InternalWriteEnd(JsonContainerType.Constructor);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteEnd(JsonContainerType container)
|
||||||
|
{
|
||||||
|
AutoCompleteClose(container);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -372,6 +377,11 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the property.</param>
|
/// <param name="name">The name of the property.</param>
|
||||||
public virtual void WritePropertyName(string name)
|
public virtual void WritePropertyName(string name)
|
||||||
|
{
|
||||||
|
InternalWritePropertyName(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWritePropertyName(string name)
|
||||||
{
|
{
|
||||||
_currentPosition.PropertyName = name;
|
_currentPosition.PropertyName = name;
|
||||||
AutoComplete(JsonToken.PropertyName);
|
AutoComplete(JsonToken.PropertyName);
|
||||||
@@ -564,21 +574,6 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private JsonContainerType GetTypeForCloseToken(JsonToken token)
|
|
||||||
{
|
|
||||||
switch (token)
|
|
||||||
{
|
|
||||||
case JsonToken.EndObject:
|
|
||||||
return JsonContainerType.Object;
|
|
||||||
case JsonToken.EndArray:
|
|
||||||
return JsonContainerType.Array;
|
|
||||||
case JsonToken.EndConstructor:
|
|
||||||
return JsonContainerType.Constructor;
|
|
||||||
default:
|
|
||||||
throw JsonWriterException.Create(this, "No type for token: " + token, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private JsonToken GetCloseTokenForType(JsonContainerType type)
|
private JsonToken GetCloseTokenForType(JsonContainerType type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
@@ -699,22 +694,16 @@ namespace Newtonsoft.Json
|
|||||||
{
|
{
|
||||||
WriteValueDelimiter();
|
WriteValueDelimiter();
|
||||||
}
|
}
|
||||||
else if (_currentState == State.Property)
|
|
||||||
{
|
|
||||||
if (_formatting == Formatting.Indented)
|
|
||||||
WriteIndentSpace();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_formatting == Formatting.Indented)
|
if (_formatting == Formatting.Indented)
|
||||||
{
|
{
|
||||||
WriteState writeState = WriteState;
|
if (_currentState == State.Property)
|
||||||
|
WriteIndentSpace();
|
||||||
|
|
||||||
// don't indent a property when it is the first token to be written (i.e. at the start)
|
// don't indent a property when it is the first token to be written (i.e. at the start)
|
||||||
if ((tokenBeingWritten == JsonToken.PropertyName && writeState != WriteState.Start) ||
|
if ((_currentState == State.Array || _currentState == State.ArrayStart || _currentState == State.Constructor || _currentState == State.ConstructorStart)
|
||||||
writeState == WriteState.Array || writeState == WriteState.Constructor)
|
|| (tokenBeingWritten == JsonToken.PropertyName && _currentState != State.Start))
|
||||||
{
|
|
||||||
WriteIndent();
|
WriteIndent();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_currentState = newState;
|
_currentState = newState;
|
||||||
@@ -725,6 +714,11 @@ namespace Newtonsoft.Json
|
|||||||
/// Writes a null value.
|
/// Writes a null value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteNull()
|
public virtual void WriteNull()
|
||||||
|
{
|
||||||
|
InternalWriteNull();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteNull()
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
UpdateScopeWithFinishedValue();
|
||||||
AutoComplete(JsonToken.Null);
|
AutoComplete(JsonToken.Null);
|
||||||
@@ -734,6 +728,11 @@ namespace Newtonsoft.Json
|
|||||||
/// Writes an undefined value.
|
/// Writes an undefined value.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void WriteUndefined()
|
public virtual void WriteUndefined()
|
||||||
|
{
|
||||||
|
InternalWriteUndefined();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteUndefined()
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
UpdateScopeWithFinishedValue();
|
||||||
AutoComplete(JsonToken.Undefined);
|
AutoComplete(JsonToken.Undefined);
|
||||||
@@ -744,6 +743,11 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="json">The raw JSON to write.</param>
|
/// <param name="json">The raw JSON to write.</param>
|
||||||
public virtual void WriteRaw(string json)
|
public virtual void WriteRaw(string json)
|
||||||
|
{
|
||||||
|
InternalWriteRaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteRaw()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -764,9 +768,14 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="value">The <see cref="String"/> value to write.</param>
|
/// <param name="value">The <see cref="String"/> value to write.</param>
|
||||||
public virtual void WriteValue(string value)
|
public virtual void WriteValue(string value)
|
||||||
|
{
|
||||||
|
InternalWriteValue(JsonToken.String);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteValue(JsonToken token)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
UpdateScopeWithFinishedValue();
|
||||||
AutoComplete(JsonToken.String);
|
AutoComplete(token);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -775,8 +784,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int32"/> value to write.</param>
|
/// <param name="value">The <see cref="Int32"/> value to write.</param>
|
||||||
public virtual void WriteValue(int value)
|
public virtual void WriteValue(int value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -786,8 +794,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public virtual void WriteValue(uint value)
|
public virtual void WriteValue(uint value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -796,8 +803,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int64"/> value to write.</param>
|
/// <param name="value">The <see cref="Int64"/> value to write.</param>
|
||||||
public virtual void WriteValue(long value)
|
public virtual void WriteValue(long value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -807,8 +813,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public virtual void WriteValue(ulong value)
|
public virtual void WriteValue(ulong value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -817,8 +822,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Single"/> value to write.</param>
|
/// <param name="value">The <see cref="Single"/> value to write.</param>
|
||||||
public virtual void WriteValue(float value)
|
public virtual void WriteValue(float value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Float);
|
||||||
AutoComplete(JsonToken.Float);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -827,8 +831,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Double"/> value to write.</param>
|
/// <param name="value">The <see cref="Double"/> value to write.</param>
|
||||||
public virtual void WriteValue(double value)
|
public virtual void WriteValue(double value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Float);
|
||||||
AutoComplete(JsonToken.Float);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -837,8 +840,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Boolean"/> value to write.</param>
|
/// <param name="value">The <see cref="Boolean"/> value to write.</param>
|
||||||
public virtual void WriteValue(bool value)
|
public virtual void WriteValue(bool value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Boolean);
|
||||||
AutoComplete(JsonToken.Boolean);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -847,8 +849,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Int16"/> value to write.</param>
|
/// <param name="value">The <see cref="Int16"/> value to write.</param>
|
||||||
public virtual void WriteValue(short value)
|
public virtual void WriteValue(short value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -858,8 +859,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public virtual void WriteValue(ushort value)
|
public virtual void WriteValue(ushort value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -868,8 +868,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Char"/> value to write.</param>
|
/// <param name="value">The <see cref="Char"/> value to write.</param>
|
||||||
public virtual void WriteValue(char value)
|
public virtual void WriteValue(char value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.String);
|
||||||
AutoComplete(JsonToken.String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -878,8 +877,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Byte"/> value to write.</param>
|
/// <param name="value">The <see cref="Byte"/> value to write.</param>
|
||||||
public virtual void WriteValue(byte value)
|
public virtual void WriteValue(byte value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -889,8 +887,7 @@ namespace Newtonsoft.Json
|
|||||||
[CLSCompliant(false)]
|
[CLSCompliant(false)]
|
||||||
public virtual void WriteValue(sbyte value)
|
public virtual void WriteValue(sbyte value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Integer);
|
||||||
AutoComplete(JsonToken.Integer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -899,8 +896,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Decimal"/> value to write.</param>
|
/// <param name="value">The <see cref="Decimal"/> value to write.</param>
|
||||||
public virtual void WriteValue(decimal value)
|
public virtual void WriteValue(decimal value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Float);
|
||||||
AutoComplete(JsonToken.Float);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -909,8 +905,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
/// <param name="value">The <see cref="DateTime"/> value to write.</param>
|
||||||
public virtual void WriteValue(DateTime value)
|
public virtual void WriteValue(DateTime value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Date);
|
||||||
AutoComplete(JsonToken.Date);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !PocketPC && !NET20
|
#if !PocketPC && !NET20
|
||||||
@@ -920,8 +915,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="DateTimeOffset"/> value to write.</param>
|
/// <param name="value">The <see cref="DateTimeOffset"/> value to write.</param>
|
||||||
public virtual void WriteValue(DateTimeOffset value)
|
public virtual void WriteValue(DateTimeOffset value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.Date);
|
||||||
AutoComplete(JsonToken.Date);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -931,8 +925,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="Guid"/> value to write.</param>
|
/// <param name="value">The <see cref="Guid"/> value to write.</param>
|
||||||
public virtual void WriteValue(Guid value)
|
public virtual void WriteValue(Guid value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.String);
|
||||||
AutoComplete(JsonToken.String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -941,8 +934,7 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="value">The <see cref="TimeSpan"/> value to write.</param>
|
/// <param name="value">The <see cref="TimeSpan"/> value to write.</param>
|
||||||
public virtual void WriteValue(TimeSpan value)
|
public virtual void WriteValue(TimeSpan value)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteValue(JsonToken.String);
|
||||||
AutoComplete(JsonToken.String);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1162,14 +1154,9 @@ namespace Newtonsoft.Json
|
|||||||
public virtual void WriteValue(byte[] value)
|
public virtual void WriteValue(byte[] value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
|
||||||
WriteNull();
|
WriteNull();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
InternalWriteValue(JsonToken.Bytes);
|
||||||
UpdateScopeWithFinishedValue();
|
|
||||||
AutoComplete(JsonToken.Bytes);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1179,14 +1166,9 @@ namespace Newtonsoft.Json
|
|||||||
public virtual void WriteValue(Uri value)
|
public virtual void WriteValue(Uri value)
|
||||||
{
|
{
|
||||||
if (value == null)
|
if (value == null)
|
||||||
{
|
|
||||||
WriteNull();
|
WriteNull();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
InternalWriteValue(JsonToken.String);
|
||||||
UpdateScopeWithFinishedValue();
|
|
||||||
AutoComplete(JsonToken.String);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -1297,7 +1279,11 @@ namespace Newtonsoft.Json
|
|||||||
/// <param name="text">Text to place inside the comment.</param>
|
/// <param name="text">Text to place inside the comment.</param>
|
||||||
public virtual void WriteComment(string text)
|
public virtual void WriteComment(string text)
|
||||||
{
|
{
|
||||||
UpdateScopeWithFinishedValue();
|
InternalWriteComment();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteComment()
|
||||||
|
{
|
||||||
AutoComplete(JsonToken.Comment);
|
AutoComplete(JsonToken.Comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1306,6 +1292,11 @@ namespace Newtonsoft.Json
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ws">The string of white space characters.</param>
|
/// <param name="ws">The string of white space characters.</param>
|
||||||
public virtual void WriteWhitespace(string ws)
|
public virtual void WriteWhitespace(string ws)
|
||||||
|
{
|
||||||
|
InternalWriteWhitespace(ws);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void InternalWriteWhitespace(string ws)
|
||||||
{
|
{
|
||||||
if (ws != null)
|
if (ws != null)
|
||||||
{
|
{
|
||||||
@@ -1314,7 +1305,6 @@ namespace Newtonsoft.Json
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void IDisposable.Dispose()
|
void IDisposable.Dispose()
|
||||||
{
|
{
|
||||||
Dispose(true);
|
Dispose(true);
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ using System.Security;
|
|||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
[assembly: AssemblyVersion("4.5.0.0")]
|
[assembly: AssemblyVersion("4.5.0.0")]
|
||||||
#if !PocketPC
|
#if !PocketPC
|
||||||
[assembly: AssemblyFileVersion("4.5.10.15431")]
|
[assembly: AssemblyFileVersion("4.5.10.15501")]
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
|
|||||||
Reference in New Issue
Block a user