I need to convert this type of json
{
"italy":[
{
"city":"rome",
"people":100000
},
{
"city":"milan",
"people":50000
}
],
"spain":[
{
"city":"barcelona",
"people":100000
},
{
"city":"madrid",
"people":2000
}
]
}
into a list of this c# class
class CityPeople
{
public string City { get; set; }
public string Country { get; set; }
public int People { get; set; }
}
so, in this specific case i would like to have a List composed of 4 entries, 2 for italy and 2 for spain.
How can i deserialize the json into this class?
i tried to do a sandard deserialize like this but without success because the json is not a jsonarray
List<CityPeople> citiesPeople = JsonConvert.DeserializeObject<List<CityPeople>>(myJson);
>` on those json properties.
– dcg Jun 13 '17 at 14:48