tags:

views:

25

answers:

0

Hi i am using json.net for converting a json string, 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}

now the incentive_type i have declared 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; }
}

now 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 i am new to json please help me. Thank you.