I am using Json.NET for converting a JSON string, and I am just pasting a small string here:
"incentive_type":{"cost":0,"id":4}
"incentive_type":{"cost":{"points":400,"denom":null,"acc":{"foil":{},"rates":{}}},"id":4}
I have declared incentive_type
as:
public class incentive_type
{
public cost cost { get; set; }
public int id { get; set; }
}
public class cost
{
public cost()
{
}
public Dictionary<string,int> points { get; set; }
public Dictionary<string,string> denom { get; set; }
public acc acc { get; set; }
}
public class acc
{
public Dictionary<string,int> foil{ get; set; }
public Dictionary<string,int> rates { get; set; }
}
While deserializing I am getting
cannot convert 0 to type'cost'
The reason is the first JSON string which has 0 for class. How can I set my class to handle this value?