-Documentation
This commit is contained in:
+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