Please see the JSON below, which I have validated using https://jsonlint.com/:
{
"People": {
"data": [{
"id": "1",
"name": "Bert"
},
{
"id": "2",
"name": "Brian"
},
{
"id": "3",
"name": "Maria"
}
]
}
}
I am trying to deserialize this JSON into a class like this:
public class Person
{
public string id;
public string name
}
So far I have tried this:
public static List<Person> DeserializePeople(string json)
{
var jo = JObject.Parse(json);
return jo["data"]["People"]
.Select(s => new Person
{
id = ((string)s[0] == null) ? "" : (string)s[0],
name = ((string)s[1] == null) ? "" : (string)s[1],
})
.ToList();
}