Language C#. Console Application.
I have a json document in following format:
{"Cars":{"Mercedes": 1,"BMW": 3,"Toyota": 0},"Bikes":{"Kawasaki": 5,"Pulsar": 4}}
I have following classes:
public class Vehicles
{
public Cars cars {get; set;}
public Bikes bikes {get; set;}
}
public class Cars
{
Dictionary<string, int> carcount {get; set;}
}
public class Bikes
{
Dictionary<string, int> bikecount {get; set;}
}
I have to deserialize the json into the class. I tried this
Vehicles jsondata = JsonConvert.DesrializeObject<Vehicles>(jsonstring);
I get the dictionaries in both bikes and cars as null. I know I am missing something very basic. But cannot figure out exactly what.
Also, the json string format cannot change. Class structure can change though.