-Improved documentation

This commit is contained in:
James Newton-King
2012-07-27 22:57:08 +12:00
parent 2097219ec9
commit 29f1ed9cd0
18 changed files with 173 additions and 46 deletions
+18 -10
View File
@@ -9,13 +9,26 @@
namespace.</para> namespace.</para>
</introduction> </introduction>
<section>
<title>Reading JSON</title>
<content>
<para>JSON values can be read from a string use the
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Parse(System.String)</codeEntityReference>
method.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Parsing a JSON Object from Text" />
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParseArray" title="Parsing a JSON Array from Text" />
</content>
</section>
<section> <section>
<title>Creating JSON</title> <title>Creating JSON</title>
<content> <content>
<!-- Uncomment this to create a sub-section outline <!-- Uncomment this to create a sub-section outline
<autoOutline /> --> <autoOutline /> -->
<para>There are a number of different options when it comes to creating <para>There are a number of different options when it comes to creating
JSON using LINQ to JSON. The first to create objects imperatively. You JSON using LINQ to JSON.</para>
<para>The first to create objects imperatively. You
have total control but it is more verbose than other options.</para> have total control but it is more verbose than other options.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateNormal" title="Creating JSON" /> <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateNormal" title="Creating JSON" />
@@ -24,17 +37,12 @@
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateDeclaratively" title="Creating JSON Declaratively" /> <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateDeclaratively" title="Creating JSON Declaratively" />
<para>You can create a JSON object from a non-JSON type using the <para>Finally you can create a JSON object from a non-JSON type using the
<codeEntityReference>Overload:Newtonsoft.Json.Linq.JObject.FromObject</codeEntityReference> <codeEntityReference>Overload:Newtonsoft.Json.Linq.JObject.FromObject</codeEntityReference>
method.</para> method. The example below is creating a JSON object from an anonymous object but any
.NET type can be used with FromObject.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateFromObject" title="Creating JSON From An Object" /> <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateFromObject" title="Creating JSON from an Object" />
<para>Finally JSON objects can be created from a string use the
<codeEntityReference>M:Newtonsoft.Json.Linq.JToken.Parse(System.String)</codeEntityReference>
method.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Creating JSON From Text" />
</content> </content>
</section> </section>
<section> <section>
+23 -1
View File
@@ -5,11 +5,29 @@
<para>To manually read and write JSON Json.NET provides the <para>To manually read and write JSON Json.NET provides the
<codeEntityReference>T:Newtonsoft.Json.JsonReader</codeEntityReference> <codeEntityReference>T:Newtonsoft.Json.JsonReader</codeEntityReference>
and and
<codeEntityReference>T:Newtonsoft.Json.JsonWriter</codeEntityReference> classes. These are low level classes and used internally by Json.NET.</para> <codeEntityReference>T:Newtonsoft.Json.JsonWriter</codeEntityReference> classes.</para>
</introduction> </introduction>
<section> <section>
<title>JsonTextReader and JsonTextWriter</title> <title>JsonTextReader and JsonTextWriter</title>
<content> <content>
<alert class="note">
<para>JsonReader and JsonWriter are low level classes and used internally by Json.NET.
To quickly work with JSON either the serializer -
<externalLink>
<linkText>Serializing and Deserializing JSON</linkText>
<linkUri>SerializingJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
or using <externalLink>
<linkText>LINQ to JSON</linkText>
<linkUri>LINQtoJSON.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink> is recommended.
</para>
</alert>
<para><codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference> <para><codeEntityReference>T:Newtonsoft.Json.JsonTextReader</codeEntityReference>
and <codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference> and <codeEntityReference>T:Newtonsoft.Json.JsonTextWriter</codeEntityReference>
are used to read and write JSON text. are used to read and write JSON text.
@@ -18,6 +36,10 @@
count and quote character.</para> count and quote character.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ReadingAndWritingJsonTests.cs" region="ReadingAndWritingJsonText" title="Writing JSON with JsonTextWriter" /> <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ReadingAndWritingJsonTests.cs" region="ReadingAndWritingJsonText" title="Writing JSON with JsonTextWriter" />
<para>JsonTextReader has settings on it for reading different date formats and time zones, and
the culture used when reading text values.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\ReadingAndWritingJsonTests.cs" region="ReadingJsonText" title="Reading JSON with JsonTextReader" />
</content> </content>
</section> </section>
<section> <section>
+5
View File
@@ -193,6 +193,11 @@
dictionary name/values will be written to the JSON object when serializing and properties on the JSON object will dictionary name/values will be written to the JSON object when serializing and properties on the JSON object will
be added to the dictionary's name/values when deserializing. Additional members on the .NET dictionary are ignored be added to the dictionary's name/values when deserializing. Additional members on the .NET dictionary are ignored
during serialization.</para> during serialization.</para>
<para>When serializing a dictionary the keys of the dictionary are converted to strings and used as the
JSON object property names. The string written for a key can be customized by either overriding
<codeEntityReference>M:System.Object.ToString</codeEntityReference> for the key type or by implementing a
<codeEntityReference>T:System.ComponentModel.TypeConverter</codeEntityReference>. A TypeConverter will also
support converting a custom string back again when deserializing a dictionary.</para>
<para>JsonDictionaryAttribute has options on it to customize the JsonConverter, type name handling and reference <para>JsonDictionaryAttribute has options on it to customize the JsonConverter, type name handling and reference
handling that are applied to collection items.</para> handling that are applied to collection items.</para>
<para>When deserializing if a member is typed as the interface IDictionary&lt;TKey, TValue&gt; then it will be <para>When deserializing if a member is typed as the interface IDictionary&lt;TKey, TValue&gt; then it will be
+18 -15
View File
@@ -13,7 +13,7 @@
<section> <section>
<title>DateFormatHandling</title> <title>DateFormatHandling</title>
<content><para>DateFormatHandling controls how dates are serialized.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.DateFormatHandling</codeEntityReference> controls how dates are serialized.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -24,11 +24,11 @@
</tableHeader> </tableHeader>
<row> <row>
<entry><para><legacyBold>IsoDateFormat</legacyBold></para></entry> <entry><para><legacyBold>IsoDateFormat</legacyBold></para></entry>
<entry><para>By default Json.NET writes dates in the ISO 8601 format, e.g. "2012-03-21T05:40Z".</para></entry> <entry><para>By default Json.NET writes dates in the ISO 8601 format, e.g. <codeInline>"2012-03-21T05:40Z"</codeInline>.</para></entry>
</row> </row>
<row> <row>
<entry><para><legacyBold>MicrosoftDateFormat</legacyBold></para></entry> <entry><para><legacyBold>MicrosoftDateFormat</legacyBold></para></entry>
<entry><para>Dates are written in the Microsoft JSON format, e.g. "\/Date(1198908717056)\/".</para></entry> <entry><para>Dates are written in the Microsoft JSON format, e.g. <codeInline>"\/Date(1198908717056)\/"</codeInline>.</para></entry>
</row> </row>
</table> </table>
@@ -37,7 +37,7 @@
<section> <section>
<title>MissingMemberHandling</title> <title>MissingMemberHandling</title>
<content><para>MissingMemberHandling controls how missing members, e.g. JSON contains a property that isn't a member on the object, are handled during deserialization.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.MissingMemberHandling</codeEntityReference> controls how missing members, e.g. JSON contains a property that isn't a member on the object, are handled during deserialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -61,7 +61,7 @@
<section> <section>
<title>ReferenceLoopHandling</title> <title>ReferenceLoopHandling</title>
<content><para>ReferenceLoopHandling controls how circular referencing objects, e.g. a Person object referencing itself via a Manager property, are serialized.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.ReferenceLoopHandling</codeEntityReference> controls how circular referencing objects, e.g. a Person object referencing itself via a Manager property, are serialized.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -89,7 +89,7 @@
<section> <section>
<title>NullValueHandling</title> <title>NullValueHandling</title>
<content><para>NullValueHandling controls how null values on .NET objects are handled during serialization and how null values in JSON are handled during deserialization.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.NullValueHandling</codeEntityReference> controls how null values on .NET objects are handled during serialization and how null values in JSON are handled during deserialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -114,7 +114,7 @@
<section> <section>
<title>DefaultValueHandling</title> <title>DefaultValueHandling</title>
<content><para>DefaultValueHandling controls how Json.NET uses default values set using the .NET DefaultValueAttribute when serializing and deserializing.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.DefaultValueHandling</codeEntityReference> controls how Json.NET uses default values set using the .NET <codeEntityReference>T:System.ComponentModel.DefaultValueAttribute</codeEntityReference> when serializing and deserializing.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -139,7 +139,7 @@
<section> <section>
<title>ObjectCreationHandling</title> <title>ObjectCreationHandling</title>
<content><para>ObjectCreationHandling controls how objects are created and deserialized to during deserialization.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.ObjectCreationHandling</codeEntityReference> controls how objects are created and deserialized to during deserialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -168,7 +168,7 @@
<section> <section>
<title>TypeNameHandling</title> <title>TypeNameHandling</title>
<content><para>TypeNameHandling controls whether Json.NET includes .NET type names during serialization with a $type property and reads .NET type names from that property to determine what type to create during deserialization.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.TypeNameHandling</codeEntityReference> controls whether Json.NET includes .NET type names during serialization with a $type property and reads .NET type names from that property to determine what type to create during deserialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -205,7 +205,7 @@
<section> <section>
<title>TypeNameAssemblyFormat</title> <title>TypeNameAssemblyFormat</title>
<content><para>TypeNameAssemblyFormat controls how type names are written during serialization.</para> <content><para><codeEntityReference>T:System.Runtime.Serialization.Formatters.FormatterAssemblyStyle</codeEntityReference> controls how type names are written during serialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -230,14 +230,14 @@
<section> <section>
<title>Binder</title> <title>Binder</title>
<content><para>The serialization binder is used to resolve type names to a .NET type.</para> <content><para>The <codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference> is used to resolve type names to a .NET type.</para>
<para>Read more about the serialization binder here: <codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference></para> <para>Read more about the serialization binder here: <codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference></para>
</content> </content>
</section> </section>
<section> <section>
<title>ConstructorHandling</title> <title>ConstructorHandling</title>
<content><para>ConstructorHandling controls how constructors are used when initializing objects during deserialization.</para> <content><para><codeEntityReference>T:Newtonsoft.Json.ConstructorHandling</codeEntityReference> controls how constructors are used when initializing objects during deserialization.</para>
<table> <table>
<tableHeader> <tableHeader>
@@ -265,7 +265,7 @@
<section> <section>
<title>Converters</title> <title>Converters</title>
<content><para>This is the collection of JsonConverters that will be used during serialization and deserialization.</para> <content><para>This is the collection of JsonConverters that will be used during serialization and deserialization.</para>
<para>JsonConverters allows JSON to be manually written during serialization and read during deserialization. <para>A <codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference> allows JSON to be manually written during serialization and read during deserialization.
This is useful for particularly complex JSON structures or for when you want to change how a type is serialized.</para> This is useful for particularly complex JSON structures or for when you want to change how a type is serialized.</para>
<para>When a JsonConverter has been added to a JsonSerializer it will be checked for every value that is being serialized/deserialized <para>When a JsonConverter has been added to a JsonSerializer it will be checked for every value that is being serialized/deserialized
using its CanConvert to see if it should be used. If CanConvert returns true then the JsonConverter will be used to read or write using its CanConvert to see if it should be used. If CanConvert returns true then the JsonConverter will be used to read or write
@@ -300,7 +300,8 @@
<section> <section>
<title>ContractResolver</title> <title>ContractResolver</title>
<content><para>Internally for every .NET type the JsonSerializer will create a contract of how the type should be serialized and deserialized, <content><para>Internally for every .NET type the JsonSerializer will create a contract of how the type should be serialized and deserialized,
based on type metadata and attributes applied to the class. Specifying a custom IContractResolver allows the creation of contracts to be customized.</para> based on type metadata and attributes applied to the class. Specifying a custom <codeEntityReference>T:Newtonsoft.Json.Serialization.IContractResolver</codeEntityReference>
allows the creation of contracts to be customized.</para>
<para>Read more about Contract Resolvers here: <externalLink> <para>Read more about Contract Resolvers here: <externalLink>
<linkText>Contract Resolvers</linkText> <linkText>Contract Resolvers</linkText>
<linkUri>ContractResolver.htm</linkUri> <linkUri>ContractResolver.htm</linkUri>
@@ -311,7 +312,7 @@
<section> <section>
<title>Error</title> <title>Error</title>
<content><para>The Error event can catch errors during serialization and either handle the event and continue with <content><para>The <codeEntityReference>E:Newtonsoft.Json.JsonSerializer.Error</codeEntityReference> event can catch errors during serialization and either handle the event and continue with
serialization or let the error bubble up and be thrown to the application.</para> serialization or let the error bubble up and be thrown to the application.</para>
<para>Read more about error handling here: <externalLink> <para>Read more about error handling here: <externalLink>
<linkText>Serialization Error Handling</linkText> <linkText>Serialization Error Handling</linkText>
@@ -340,6 +341,8 @@
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference> <codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference> <codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonConverter</codeEntityReference>
<codeEntityReference>T:System.Runtime.Serialization.SerializationBinder</codeEntityReference>
</relatedTopics> </relatedTopics>
</developerConceptualDocument> </developerConceptualDocument>
</topic> </topic>
+5
View File
@@ -54,6 +54,11 @@
</content> </content>
</section> </section>
<relatedTopics> <relatedTopics>
<externalLink>
<linkText>Serialization Guide</linkText>
<linkUri>SerializationGuide.htm</linkUri>
<linkTarget>_self</linkTarget>
</externalLink>
<codeEntityReference>T:Newtonsoft.Json.JsonConvert</codeEntityReference> <codeEntityReference>T:Newtonsoft.Json.JsonConvert</codeEntityReference>
<codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference> <codeEntityReference>T:Newtonsoft.Json.JsonSerializer</codeEntityReference>
</relatedTopics> </relatedTopics>
+1 -1
View File
@@ -19,7 +19,7 @@
<codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.SerializeObject</codeEntityReference> and <codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.SerializeObject</codeEntityReference> and
<codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.DeserializeObject</codeEntityReference> <codeEntityReference>Overload:Newtonsoft.Json.JsonConvert.DeserializeObject</codeEntityReference>
methods on JsonConvert provide an easy to use wrapper over JsonSerializer.</para> methods on JsonConvert provide an easy to use wrapper over JsonSerializer.</para>
<code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializeObject" title="Serializing JSON with JsonConvert" /> <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializeObject" title="Serializing and Deserializing JSON with JsonConvert" />
<para> <para>
SerializeObject and DeserializeObject both have overloads that take a <codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference> object. SerializeObject and DeserializeObject both have overloads that take a <codeEntityReference>T:Newtonsoft.Json.JsonSerializerSettings</codeEntityReference> object.
JsonSerializerSettings lets you use many of the JsonSerializer settings listed below while still using the simple serialization methods. JsonSerializerSettings lets you use many of the JsonSerializer settings listed below while still using the simple serialization methods.
@@ -64,7 +64,7 @@ namespace Newtonsoft.Json.Tests.Documentation
string json = array.ToString(); string json = array.ToString();
// [ // [
// "Manual text", // "Manual text",
// "\/Date(958996800000+1200)\/" // "2000-05-23T00:00:00"
// ] // ]
#endregion #endregion
} }
@@ -173,7 +173,7 @@ namespace Newtonsoft.Json.Tests.Documentation
CPU: 'Intel', CPU: 'Intel',
Drives: [ Drives: [
'DVD read/writer', 'DVD read/writer',
""500 gigabyte hard drive"" '500 gigabyte hard drive'
] ]
}"; }";
@@ -181,6 +181,19 @@ namespace Newtonsoft.Json.Tests.Documentation
#endregion #endregion
} }
public void LinqToJsonCreateParseArray()
{
#region LinqToJsonCreateParseArray
string json = @"[
'Small',
'Medium',
'Large'
]";
JArray a = JArray.Parse(json);
#endregion
}
public void LinqToJsonQuerying() public void LinqToJsonQuerying()
{ {
JObject rss = new JObject(); JObject rss = new JObject();
@@ -49,7 +49,8 @@ using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
namespace Newtonsoft.Json.Tests.Documentation namespace Newtonsoft.Json.Tests.Documentation
{ {
public class ReadingAndWritingJsonTests [TestFixture]
public class ReadingAndWritingJsonTests : TestFixtureBase
{ {
public void ReadingAndWritingJsonText() public void ReadingAndWritingJsonText()
{ {
@@ -89,6 +90,46 @@ namespace Newtonsoft.Json.Tests.Documentation
#endregion #endregion
} }
[Test]
public void ReadingJsonText()
{
#region ReadingJsonText
string json = @"{
'CPU': 'Intel',
'PSU': '500W',
'Drives': [
'DVD read/writer'
/*(broken)*/,
'500 gigabyte hard drive',
'200 gigabype hard drive'
]
}";
JsonTextReader reader = new JsonTextReader(new StringReader(json));
while (reader.Read())
{
if (reader.Value != null)
Console.WriteLine("Token: {0}, Value: {1}", reader.TokenType, reader.Value);
else
Console.WriteLine("Token: {0}", reader.TokenType);
}
// Token: StartObject
// Token: PropertyName, Value: CPU
// Token: String, Value: Intel
// Token: PropertyName, Value: PSU
// Token: String, Value: 500W
// Token: PropertyName, Value: Drives
// Token: StartArray
// Token: String, Value: DVD read/writer
// Token: Comment, Value: (broken)
// Token: String, Value: 500 gigabyte hard drive
// Token: String, Value: 200 gigabype hard drive
// Token: EndArray
// Token: EndObject
#endregion
}
public void ReadingAndWritingJsonLinq() public void ReadingAndWritingJsonLinq()
{ {
#region ReadingAndWritingJsonLinq #region ReadingAndWritingJsonLinq
@@ -332,13 +332,13 @@ namespace Newtonsoft.Json.Tests.Documentation
//[ //[
// { // {
// "Name": "James", // "Name": "James",
// "BirthDate": "\/Date(346377600000)\/", // "BirthDate": "1980-12-23T00:00:00Z",
// "LastModified": "\/Date(1235134761000)\/" // "LastModified": "2009-02-20T12:59:21Z"
// }, // },
// { // {
// "Name": "James", // "Name": "James",
// "BirthDate": "\/Date(346377600000)\/", // "BirthDate": "1980-12-23T00:00:00Z",
// "LastModified": "\/Date(1235134761000)\/" // "LastModified": "2009-02-20T12:59:21Z"
// } // }
//] //]
#endregion #endregion
@@ -356,8 +356,8 @@ namespace Newtonsoft.Json.Tests.Documentation
// { // {
// "$id": "1", // "$id": "1",
// "Name": "James", // "Name": "James",
// "BirthDate": "\/Date(346377600000)\/", // "BirthDate": "1983-03-08T00:00Z",
// "LastModified": "\/Date(1235134761000)\/" // "LastModified": "2012-03-21T05:40Z"
// }, // },
// { // {
// "$ref": "1" // "$ref": "1"
@@ -428,14 +428,14 @@ namespace Newtonsoft.Json.Tests.Documentation
// { // {
// "FirstName": "Maurice", // "FirstName": "Maurice",
// "LastName": "Moss", // "LastName": "Moss",
// "BirthDate": "\/Date(252291661000)\/", // "BirthDate": "1981-03-08T00:00Z",
// "Department": "IT", // "Department": "IT",
// "JobTitle": "Support" // "JobTitle": "Support"
// }, // },
// { // {
// "FirstName": "Jen", // "FirstName": "Jen",
// "LastName": "Barber", // "LastName": "Barber",
// "BirthDate": "\/Date(258771661000)\/", // "BirthDate": "1985-12-10T00:00Z",
// "Department": "IT", // "Department": "IT",
// "JobTitle": "Manager" // "JobTitle": "Manager"
// } // }
@@ -478,7 +478,7 @@ namespace Newtonsoft.Json.Tests.Documentation
//{ //{
// "name": "Widget", // "name": "Widget",
// "expiryDate": "\/Date(1292868060000)\/", // "expiryDate": "2010-12-20T18:01Z",
// "price": 9.99, // "price": 9.99,
// "sizes": [ // "sizes": [
// "Small", // "Small",
@@ -513,13 +513,13 @@ namespace Newtonsoft.Json.Tests.Documentation
//[ //[
// { // {
// "Name": "Product 1", // "Name": "Product 1",
// "ExpiryDate": "\/Date(978048000000)\/", // "ExpiryDate": "2000-12-29T00:00Z",
// "Price": 99.95, // "Price": 99.95,
// "Sizes": null // "Sizes": null
// }, // },
// { // {
// "Name": "Product 2", // "Name": "Product 2",
// "ExpiryDate": "\/Date(1248998400000)\/", // "ExpiryDate": "2009-07-31T00:00Z",
// "Price": 12.50, // "Price": 12.50,
// "Sizes": null // "Sizes": null
// } // }
@@ -533,13 +533,13 @@ namespace Newtonsoft.Json.Tests.Documentation
string json = @"[ string json = @"[
{ {
'Name': 'Product 1', 'Name': 'Product 1',
'ExpiryDate': '\/Date(978048000000)\/', 'ExpiryDate': '2000-12-29T00:00Z',
'Price': 99.95, 'Price': 99.95,
'Sizes': null 'Sizes': null
}, },
{ {
'Name': 'Product 2', 'Name': 'Product 2',
'ExpiryDate': '\/Date(1248998400000)\/', 'ExpiryDate': '2009-07-31T00:00Z',
'Price': 12.50, 'Price': 12.50,
'Sizes': null 'Sizes': null
} }
@@ -72,5 +72,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.7.15122")] [assembly: AssemblyFileVersion("4.5.7.15127")]
#endif #endif
@@ -30,6 +30,10 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Specifies default value handling options for the <see cref="JsonSerializer"/>. /// Specifies default value handling options for the <see cref="JsonSerializer"/>.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeDefaultValueHandlingObject" title="DefaultValueHandling Class" />
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeDefaultValueHandlingExample" title="DefaultValueHandling Ignore Example" />
/// </example>
[Flags] [Flags]
public enum DefaultValueHandling public enum DefaultValueHandling
{ {
+3
View File
@@ -45,6 +45,9 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Provides methods for converting between common language runtime types and JSON types. /// Provides methods for converting between common language runtime types and JSON types.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="SerializeObject" title="Serializing and Deserializing JSON with JsonConvert" />
/// </example>
public static class JsonConvert public static class JsonConvert
{ {
/// <summary> /// <summary>
+6
View File
@@ -34,6 +34,9 @@ namespace Newtonsoft.Json.Linq
/// <summary> /// <summary>
/// Represents a JSON array. /// Represents a JSON array.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParseArray" title="Parsing a JSON Array from Text" />
/// </example>
public class JArray : JContainer, IList<JToken> public class JArray : JContainer, IList<JToken>
{ {
private readonly IList<JToken> _values = new List<JToken>(); private readonly IList<JToken> _values = new List<JToken>();
@@ -135,6 +138,9 @@ namespace Newtonsoft.Json.Linq
/// </summary> /// </summary>
/// <param name="json">A <see cref="String"/> that contains JSON.</param> /// <param name="json">A <see cref="String"/> that contains JSON.</param>
/// <returns>A <see cref="JArray"/> populated from the string that contains JSON.</returns> /// <returns>A <see cref="JArray"/> populated from the string that contains JSON.</returns>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParseArray" title="Parsing a JSON Array from Text" />
/// </example>
public static new JArray Parse(string json) public static new JArray Parse(string json)
{ {
JsonReader reader = new JsonTextReader(new StringReader(json)); JsonReader reader = new JsonTextReader(new StringReader(json));
+6
View File
@@ -48,6 +48,9 @@ namespace Newtonsoft.Json.Linq
/// <summary> /// <summary>
/// Represents a JSON object. /// Represents a JSON object.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Parsing a JSON Object from Text" />
/// </example>
public class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged public class JObject : JContainer, IDictionary<string, JToken>, INotifyPropertyChanged
#if !(SILVERLIGHT || NETFX_CORE || PORTABLE) #if !(SILVERLIGHT || NETFX_CORE || PORTABLE)
, ICustomTypeDescriptor , ICustomTypeDescriptor
@@ -315,6 +318,9 @@ namespace Newtonsoft.Json.Linq
/// </summary> /// </summary>
/// <param name="json">A <see cref="String"/> that contains JSON.</param> /// <param name="json">A <see cref="String"/> that contains JSON.</param>
/// <returns>A <see cref="JObject"/> populated from the string that contains JSON.</returns> /// <returns>A <see cref="JObject"/> populated from the string that contains JSON.</returns>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\LinqToJsonTests.cs" region="LinqToJsonCreateParse" title="Parsing a JSON Object from Text" />
/// </example>
public static new JObject Parse(string json) public static new JObject Parse(string json)
{ {
JsonReader reader = new JsonTextReader(new StringReader(json)); JsonReader reader = new JsonTextReader(new StringReader(json));
+4
View File
@@ -28,6 +28,10 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Specifies null value handling options for the <see cref="JsonSerializer"/>. /// Specifies null value handling options for the <see cref="JsonSerializer"/>.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeNullValueHandlingObject" title="NullValueHandling Class" />
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeNullValueHandlingExample" title="NullValueHandling Ignore Example" />
/// </example>
public enum NullValueHandling public enum NullValueHandling
{ {
/// <summary> /// <summary>
@@ -32,6 +32,9 @@ namespace Newtonsoft.Json
/// <summary> /// <summary>
/// Specifies reference handling options for the <see cref="JsonSerializer"/>. /// Specifies reference handling options for the <see cref="JsonSerializer"/>.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="PreservingObjectReferencesOn" title="Preserve Object References" />
/// </example>
[Flags] [Flags]
public enum PreserveReferencesHandling public enum PreserveReferencesHandling
{ {
@@ -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.7.15122")] [assembly: AssemblyFileVersion("4.5.7.15127")]
#endif #endif
[assembly: CLSCompliant(true)] [assembly: CLSCompliant(true)]
@@ -30,6 +30,10 @@ namespace Newtonsoft.Json.Serialization
/// <summary> /// <summary>
/// Used by <see cref="JsonSerializer"/> to resolves a <see cref="JsonContract"/> for a given <see cref="Type"/>. /// Used by <see cref="JsonSerializer"/> to resolves a <see cref="JsonContract"/> for a given <see cref="Type"/>.
/// </summary> /// </summary>
/// <example>
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeContractResolverObject" title="IContractResolver Class" />
/// <code lang="cs" source="..\Src\Newtonsoft.Json.Tests\Documentation\SerializationTests.cs" region="ReducingSerializedJsonSizeContractResolverExample" title="IContractResolver Example" />
/// </example>
public interface IContractResolver public interface IContractResolver
{ {
/// <summary> /// <summary>