Click or drag to resize
Json.NETDeserialize an Object
 

This sample deserializes JSON to an object.

Sample
Types
1public class Account
2{
3    public string Email { get; set; }
4    public bool Active { get; set; }
5    public DateTime CreatedDate { get; set; }
6    public IList<string> Roles { get; set; }
7}
Usage
 1string json = @"{
 2  'Email': 'james@example.com',
 3  'Active': true,
 4  'CreatedDate': '2013-01-20T00:00:00Z',
 5  'Roles': [
 6    'User',
 7    'Admin'
 8  ]
 9}";
10
11Account account = JsonConvert.DeserializeObject<Account>(json);
12
13Console.WriteLine(account.Email);
14// james@example.com