-Documentation
This commit is contained in:
@@ -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());
|
||||
|
||||
+1
-1
@@ -8,7 +8,7 @@ namespace Newtonsoft.Json.Tests.Documentation.Samples.Serializer
|
||||
{
|
||||
public class DataContractAndDataMember
|
||||
{
|
||||
#region Usage
|
||||
#region Types
|
||||
[DataContract]
|
||||
public class File
|
||||
{
|
||||
|
||||
+10
-5
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user