我使用Json.NET转换JSON字符串,我只是在这里粘贴一个小字符串:
"incentive_type":{"cost":0,"id":4}
"incentive_type":{"cost":{"points":400,"denom":null,"acc":{"foil":{},"rates":{}}},"id":4}
我已将incentive_type
声明为:
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; }
}
反序列化时我正在
无法将0转换为'cost'
原因是第一个JSON字符串,其中0表示类。如何设置我的类来处理这个值?