I have a JSON-file people.json containing multiple objects that I want to parse to a list People containing Person objects but with no luck. I get null from peopleLis and I suspect that I do something (probably a lot) wrong here. Can you guys help me out?
{
"Andrew": {
"weight": "75",
"height": "181"
},
"Nathalie": {
"weight": "68",
"height": "182"
},
"Dave": {
"weight": "83",
"height": "192"
}
}
This is the code I tried out:
public class Person
{
public int weight { get; set; }
public int height { get; set; }
}
public class People
{
public List<Person> people { get; set; }
}
static void Main(string[] args)
{
People peopleList = JsonConvert.DeserializeObject<People>(File.ReadAllText(@"C:\people.json"));
}