Skip to content

Commit

Permalink
-Fixed bugs and made improvements to help
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesNK committed Jul 22, 2012
1 parent e156978 commit 2097219
Show file tree
Hide file tree
Showing 22 changed files with 358 additions and 122 deletions.
8 changes: 7 additions & 1 deletion Doc/ContractResolver.aml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</summary>
-->
<introduction>
<para>The IContractResolver interface provides a way to customize how the
<para>The <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
interface provides a way to customize how the
JsonSerializer serializes and deserializes .NET objects to JSON.</para>
<para>Implementing the IContractResolver interface and then assigning an
instance to a JsonSerializer lets you control whether the object is
Expand Down Expand Up @@ -44,5 +45,10 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ContractResolver" title="ContractResolver" />
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.DefaultContractResolver</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
21 changes: 20 additions & 1 deletion Doc/ConvertingJSONandXML.aml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<listItem><para>Empty elements are null.</para></listItem>
</list>

<alert class="note">
<para>The version of Json.NET being used in your application will change what XML conversion methods are available.
SerializeXmlNode/DeserializeXmlNode are available when the framework supports XmlDocument,
SerializeXNode/DeserializeXNode are available when the framework supports XDocument.</para>
</alert>

</content>
</section>
<section>
Expand All @@ -36,7 +42,16 @@

<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConvertingJsonAndXmlTests.cs" region="SerializeXmlNode" title="Converting XML to JSON with SerializeXmlNode" />

</content>
<para>Because multiple nodes with a the same name at the same level are grouped together into an array
the convernsion process can produce different JSON depending on the number of nodes. For example if some
XML for a user has a single <codeInline>&lt;Role&gt;</codeInline> node then that role will be text against
a JSON <codeInline>"Role"</codeInline> property, but if the user has multiple <codeInline>&lt;Role&gt;</codeInline>
nodes then the role values will be placed in a JSON array.</para>

<para>To fix this situation a custom XML attribute can be added to force a JSON array to be created.</para>

<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ConvertingJsonAndXmlTests.cs" region="ForceJsonArray" title="Attribute to Force a JSON Array" />
</content>
</section>
<section>
<title>DeserializeXmlNode</title>
Expand All @@ -55,5 +70,9 @@

</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.Converters.XmlNodeConverter</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonConvert</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
9 changes: 5 additions & 4 deletions Doc/CustomCreationConverter.aml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@
</summary>
-->
<introduction>
<para>The CustomCreationConverter is a JsonConverter that provides a way
<para>The <codeEntityReference>T:Newtonsoft.Json.Converters.CustomCreationConverter`1</codeEntityReference>
is a JsonConverter that provides a way
to customize how an object is created during JSON deserialization. Once
the object has been created it will then have values populated onto it by
the serializer.</para>
</introduction>
<!-- Add one or more top-level section elements. These are collapsible.
If using <autoOutline />, add an address attribute to identify it
and specify a title so that it can be jumped to with a hyperlink. -->
<section>
<title>Example</title>
<content>
Expand All @@ -25,5 +23,8 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="CustomCreationConverterExample" title="CustomCreationConverter Example" />
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.Converters.CustomCreationConverter`1</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
12 changes: 9 additions & 3 deletions Doc/DatesInJSON.aml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
<linkText>ISO 8601 standard</linkText>
<linkUri>http://en.wikipedia.org/wiki/ISO_8601</linkUri>
<linkTarget>_blank</linkTarget>
</externalLink>: 2012-03-19T07:22Z.</para>
</externalLink>: <codeInline>"2012-03-19T07:22Z"</codeInline>.</para>
<para>Prior to Json.NET 4.5 dates were written using the Microsoft
format: "\/Date(1198908717056)\/". If you want to use this format, or
format: <codeInline>"\/Date(1198908717056)\/"</codeInline>. If you want to use this format, or
you want to maintain compatibility with Microsoft JSON serializers or
older versions of Json.NET then change the
<codeEntityReference>T:Newtonsoft.Json.DateFormatHandling</codeEntityReference>
Expand Down Expand Up @@ -76,7 +76,7 @@
<title>IsoDateTimeConverter</title>
<content>
<alert class="note">
<para>Since Json.NET 4.5 dates are written using the ISO 8601
<para>From Json.NET 4.5 and onwards dates are written using the ISO 8601
format by default and using this converter is unnecessary.</para>
</alert>
<para>IsoDateTimeConverter seralizes a DateTime to an <externalLink>
Expand All @@ -89,5 +89,11 @@
further customize the formatted string.</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.DateFormatHandling</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.DateTimeZoneHandling</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Converters.JavaScriptDateTimeConverter</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Converters.IsoDateTimeConverter</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
31 changes: 31 additions & 0 deletions Doc/Introduction.aml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,25 @@ and write from your objects.</para>
</content>
</section>

<section>
<title>Getting Started</title>
<content>

<list class="bullet">
<listItem><para><externalLink>
<linkText>Serializing and Deserializing JSON</linkText>
<linkUri>SerializingJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink></para></listItem>
<listItem><para><externalLink>
<linkText>LINQ to JSON</linkText>
<linkUri>LINQtoJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink></para></listItem>
</list>

</content>
</section>
<section>
<title>History</title>
<content><para>Json.NET grew out of projects I was working on in late 2005 involving JavaScript,
Expand Down Expand Up @@ -87,6 +106,18 @@ and write from your objects.</para>
</a>
</p>
</markup>
<relatedTopics>
<externalLink>
<linkText>Serializing and Deserializing JSON</linkText>
<linkUri>SerializingJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<externalLink>
<linkText>LINQ to JSON</linkText>
<linkUri>LINQtoJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
</relatedTopics>

</developerConceptualDocument>
</topic>
14 changes: 12 additions & 2 deletions Doc/LINQtoJSON.aml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
objects are
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Children</codeEntityReference>
and
<codeEntityReference>P:Newtonsoft.Json.Linq.JToken.Item(System.Object)</codeEntityReference>
.</para>
<codeEntityReference>P:Newtonsoft.Json.Linq.JToken.Item(System.Object)</codeEntityReference>.</para>

<para>Children returns all the children of that object. If it is a
JObject it will return a collection of properties to work with and if
Expand All @@ -68,5 +67,16 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonDeserializeExample" title="Deserializing Using LINQ Example" />
</content>
</section>
<relatedTopics>
<externalLink>
<linkText>Querying LINQ to JSON with SelectToken</linkText>
<linkUri>SelectToken.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>

<codeEntityReference>T:Newtonsoft.Json.Linq.JObject</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Linq.JArray</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Linq.JValue</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
5 changes: 4 additions & 1 deletion Doc/PreserveObjectReferences.aml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<section>
<title>PreserveReferencesHandling</title>
<content>
<para>Settings PreserveReferencesHandling will track object references
<para>Setting <codeEntityReference>T:Newtonsoft.Json.PreserveReferencesHandling</codeEntityReference> will track object references
when serializing and deserializing JSON.</para>

<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="PreservingObjectReferencesOn" title="Preserve Object References On" />
Expand Down Expand Up @@ -68,5 +68,8 @@
the JsonSerializer.</para>
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.PreserveReferencesHandling</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
10 changes: 9 additions & 1 deletion Doc/ReadingWritingJSON.aml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<para>To manually read and write JSON Json.NET provides the
<codeEntityReference>T:Newtonsoft.Json.JsonReader</codeEntityReference>
and
<codeEntityReference>T:Newtonsoft.Json.JsonWriter</codeEntityReference> classes.</para>
<codeEntityReference>T:Newtonsoft.Json.JsonWriter</codeEntityReference> classes. These are low level classes and used internally by Json.NET.</para>
</introduction>
<section>
<title>JsonTextReader and JsonTextWriter</title>
Expand Down Expand Up @@ -33,5 +33,13 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ReadingAndWritingJsonTests.cs" region="ReadingAndWritingJsonLinq" title="Deserializing with JTokenReader" />
</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.JsonReader</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonWriter</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Linq.JTokenReader</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Linq.JTokenWriter</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Bson.BsonReader</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Bson.BsonWriter</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
6 changes: 6 additions & 0 deletions Doc/ReducingSerializedJSONSize.aml
Original file line number Diff line number Diff line change
Expand Up @@ -123,5 +123,11 @@

</content>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.Formatting</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonIgnoreAttribute</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.DefaultValueHandling</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.NullValueHandling</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
9 changes: 9 additions & 0 deletions Doc/SelectToken.aml
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="SelectTokenLinq" title="SelectToken With LINQ Example" />
</content>
</section>
<relatedTopics>
<externalLink>
<linkText>LINQ to JSON</linkText>
<linkUri>LINQtoJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>

<codeEntityReference>Overload:Newtonsoft.Json.Linq.JToken.SelectToken</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
7 changes: 7 additions & 0 deletions Doc/SerializationAttributes.aml
Original file line number Diff line number Diff line change
Expand Up @@ -134,5 +134,12 @@
</section>
</sections>
</section>
<relatedTopics>
<codeEntityReference>T:Newtonsoft.Json.JsonObjectAttribute</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonArrayAttribute</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonDictionaryAttribute</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonPropertyAttribute</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonConverterAttribute</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
22 changes: 6 additions & 16 deletions Doc/SerializationCallbacks.aml
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,12 @@ serialization lifecycle, decorate a method with the appropraite attribute
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializationCallbacksExample" title="Serialization Callback Example" />

</content>
<!-- If a section contains a sections element, its content creates
sub-sections. These are not collapsible.
<sections>
<section address="SubSection1">
<title>Sub-section 1</title>
<content>
<para>Sub-section content.</para>
</content>
</section>
<section address="SubSection2">
<title>Sub-section 2</title>
<content>
<para>Sub-section content.</para>
</content>
</section>
</sections> -->
</section>
<relatedTopics>
<codeEntityReference>T:System.Runtime.Serialization.OnSerializingAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnSerializedAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializingAttribute</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.OnDeserializedAttribute</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
9 changes: 9 additions & 0 deletions Doc/SerializationErrorHandling.aml
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,14 @@

</content>
</section>
<relatedTopics>
<externalLink>
<linkText>Serialization Attributes</linkText>
<linkUri>SerializationAttributes.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<codeEntityReference>E:Newtonsoft.Json.JsonSerializer.Error</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.Serialization.OnErrorAttribute</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
23 changes: 21 additions & 2 deletions Doc/SerializationGuide.aml
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,26 @@
</section>

</sections>
</section>

</section>
<relatedTopics>
<externalLink>
<linkText>Serialization Settings</linkText>
<linkUri>SerializationSettings.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<externalLink>
<linkText>Serialization Attributes</linkText>
<linkUri>SerializationAttributes.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<externalLink>
<linkText>Serializing Dates in JSON</linkText>
<linkUri>DatesInJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>

<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
25 changes: 22 additions & 3 deletions Doc/SerializationSettings.aml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
</summary>
-->
<introduction>
<para>JsonSerializer has a number of properties on it to customize how it serializes JSON. These can also be used with the methods on JsonConvert via the JsonSerializerSettings overloads.</para>
<para>JsonSerializer has a number of properties on it to customize how it serializes JSON. These can also be used
with the methods on JsonConvert via the <codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference> overloads.</para>
</introduction>

<section>
Expand Down Expand Up @@ -320,7 +321,25 @@
</para>
</content>
</section>


<relatedTopics>
<externalLink>
<linkText>Serialization Guide</linkText>
<linkUri>SerializationGuide.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<externalLink>
<linkText>Serialization Attributes</linkText>
<linkUri>SerializationAttributes.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<externalLink>
<linkText>Serializing Dates in JSON</linkText>
<linkUri>DatesInJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>

<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference>
</relatedTopics>
</developerConceptualDocument>
</topic>
Loading

0 comments on commit 2097219

Please sign in to comment.