Click or drag to resize
Json.NETDeserialize an Anonymous Type
 

This sample deserializes JSON into an anonymous type.

Sample
Usage
 1var definition = new { Name = "" };
 2
 3string json1 = @"{'Name':'James'}";
 4var customer1 = JsonConvert.DeserializeAnonymousType(json1, definition);
 5
 6Console.WriteLine(customer1.Name);
 7// James
 8
 9string json2 = @"{'Name':'Mike'}";
10var customer2 = JsonConvert.DeserializeAnonymousType(json2, definition);
11
12Console.WriteLine(customer2.Name);
13// Mike