-Documentation

This commit is contained in:
James Newton-King
2013-01-29 21:02:28 +13:00
parent 1c0e2856c2
commit f98c6a0d8d
22 changed files with 57 additions and 40 deletions
@@ -58,7 +58,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
// "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",
// "description": "Annoucing the release of Json.NET 1.3, the MIT license and being available on CodePlex",
// "link": "http://james.newtonking.com/projects/json-net.aspx",
// "category": [
// "Json.NET",
@@ -12,11 +12,8 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Linq
{
#region Usage
JArray array = new JArray();
JValue text = new JValue("Manual text");
JValue date = new JValue(new DateTime(2000, 5, 23));
array.Add(text);
array.Add(date);
array.Add("Manual text");
array.Add(new DateTime(2000, 5, 23));
JObject o = new JObject();
o["MyArray"] = array;
@@ -12,7 +12,10 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Schema
public void Example()
{
#region Usage
JsonSchema schema = JsonSchema.Parse(@"{'type': 'object'}");
JsonSchema schema = new JsonSchema
{
Type = JsonSchemaType.Object
};
// serialize JsonSchema to a string and then write string to a file
File.WriteAllText(@"c:\schema.json", schema.ToString());
@@ -8,7 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
{
public class DataContractAndDataMember
{
#region Usage
#region Types
[DataContract]
public class File
{
@@ -10,14 +10,19 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
public void Example()
{
#region Usage
string json = @"{'Name':'James'}";
var definition = new {Name = ""};
var customerDefinition = new {Name = ""};
string json1 = @"{'Name':'James'}";
var customer1 = JsonConvert.DeserializeAnonymousType(json1, definition);
var customer = JsonConvert.DeserializeAnonymousType(json, customerDefinition);
Console.WriteLine(customer.Name);
Console.WriteLine(customer1.Name);
// James
string json2 = @"{'Name':'Mike'}";
var customer2 = JsonConvert.DeserializeAnonymousType(json2, definition);
Console.WriteLine(customer2.Name);
// Mike
#endregion
}
}