-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
@@ -64,7 +64,7 @@ namespace Newtonsoft.Json.Tests.Documentation
string json = array.ToString();
// [
// "Manual text",
// "\/Date(958996800000+1200)\/"
// "2000-05-23T00:00:00"
// ]
#endregion
}
@@ -173,7 +173,7 @@ namespace Newtonsoft.Json.Tests.Documentation
CPU: 'Intel',
Drives: [
'DVD read/writer',
""500 gigabyte hard drive""
'500 gigabyte hard drive'
]
}";
@@ -181,6 +181,19 @@ namespace Newtonsoft.Json.Tests.Documentation
#endregion
}
public void LinqToJsonCreateParseArray()
{
#region LinqToJsonCreateParseArray
string json = @"[
'Small',
'Medium',
'Large'
]";
JArray a = JArray.Parse(json);
#endregion
}
public void LinqToJsonQuerying()
{
JObject rss = new JObject();
@@ -49,7 +49,8 @@ using ErrorEventArgs = Newtonsoft.Json.Serialization.ErrorEventArgs;
namespace Newtonsoft.Json.Tests.Documentation
{
public class ReadingAndWritingJsonTests
[TestFixture]
public class ReadingAndWritingJsonTests : TestFixtureBase
{
public void ReadingAndWritingJsonText()
{
@@ -89,6 +90,46 @@ namespace Newtonsoft.Json.Tests.Documentation
#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()
{
#region ReadingAndWritingJsonLinq
@@ -332,13 +332,13 @@ namespace Newtonsoft.Json.Tests.Documentation
//[
// {
// "Name": "James",
// "BirthDate": "\/Date(346377600000)\/",
// "LastModified": "\/Date(1235134761000)\/"
// "BirthDate": "1980-12-23T00:00:00Z",
// "LastModified": "2009-02-20T12:59:21Z"
// },
// {
// "Name": "James",
// "BirthDate": "\/Date(346377600000)\/",
// "LastModified": "\/Date(1235134761000)\/"
// "BirthDate": "1980-12-23T00:00:00Z",
// "LastModified": "2009-02-20T12:59:21Z"
// }
//]
#endregion
@@ -356,8 +356,8 @@ namespace Newtonsoft.Json.Tests.Documentation
// {
// "$id": "1",
// "Name": "James",
// "BirthDate": "\/Date(346377600000)\/",
// "LastModified": "\/Date(1235134761000)\/"
// "BirthDate": "1983-03-08T00:00Z",
// "LastModified": "2012-03-21T05:40Z"
// },
// {
// "$ref": "1"
@@ -428,14 +428,14 @@ namespace Newtonsoft.Json.Tests.Documentation
// {
// "FirstName": "Maurice",
// "LastName": "Moss",
// "BirthDate": "\/Date(252291661000)\/",
// "BirthDate": "1981-03-08T00:00Z",
// "Department": "IT",
// "JobTitle": "Support"
// },
// {
// "FirstName": "Jen",
// "LastName": "Barber",
// "BirthDate": "\/Date(258771661000)\/",
// "BirthDate": "1985-12-10T00:00Z",
// "Department": "IT",
// "JobTitle": "Manager"
// }
@@ -478,7 +478,7 @@ namespace Newtonsoft.Json.Tests.Documentation
//{
// "name": "Widget",
// "expiryDate": "\/Date(1292868060000)\/",
// "expiryDate": "2010-12-20T18:01Z",
// "price": 9.99,
// "sizes": [
// "Small",
@@ -513,13 +513,13 @@ namespace Newtonsoft.Json.Tests.Documentation
//[
// {
// "Name": "Product 1",
// "ExpiryDate": "\/Date(978048000000)\/",
// "ExpiryDate": "2000-12-29T00:00Z",
// "Price": 99.95,
// "Sizes": null
// },
// {
// "Name": "Product 2",
// "ExpiryDate": "\/Date(1248998400000)\/",
// "ExpiryDate": "2009-07-31T00:00Z",
// "Price": 12.50,
// "Sizes": null
// }
@@ -533,13 +533,13 @@ namespace Newtonsoft.Json.Tests.Documentation
string json = @"[
{
'Name': 'Product 1',
'ExpiryDate': '\/Date(978048000000)\/',
'ExpiryDate': '2000-12-29T00:00Z',
'Price': 99.95,
'Sizes': null
},
{
'Name': 'Product 2',
'ExpiryDate': '\/Date(1248998400000)\/',
'ExpiryDate': '2009-07-31T00:00Z',
'Price': 12.50,
'Sizes': null
}