Hello I am in desperate need of some help. I have a json file, with an array of json objects. I cannot figure out how to deserialize it into a list of this object.
This is very simple to do using Newtonsoft.JSON and there is a page in the documentation covering how to deserialize an object.
Taken from the documentation page:
public class Account
{
public string Email { get; set; }
public bool Active { get; set; }
public DateTime CreatedDate { get; set; }
public IList Roles { get; set; }
}
// code to deserialize from JSON string to a typed object
string json = @"{
'Email': 'james@example.com',
'Active': true,
'CreatedDate': '2013-01-20T00:00:00Z',
'Roles': [
'User',
'Admin'
]
";
Account account = JsonConvert.DeserializeObject(json);
Console.WriteLine(account.Email);
// james@example.com