我想反序列化JSON的一些字符串这样的:JSON反序列化的子类
{"time":1506174868,"pairs":{
"AAA":{"books":8,"min":0.1,"max":1.0,"fee":0.01},
"AAX":{"books":8,"min":0.1,"max":1.0,"fee":0.01},
"AQA":{"books":8,"min":0.1,"max":1.0,"fee":0.01}
}}
其中AAA,AAX,......有上百变化
的我贴这个JSON作为在VS2017类并得到如下:
public class Rootobject
{
public int time { get; set; }
public Pairs pairs { get; set; }
}
public class Pairs
{
public AAA AAA { get; set; }
public AAX AAX { get; set; }
public AQA AQA { get; set; }
}
public class AAA
{
public int books { get; set; }
public float min { get; set; }
public float max { get; set; }
public float fee { get; set; }
}
public class AAX
{
public int books { get; set; }
public float min { get; set; }
public float max { get; set; }
public float fee { get; set; }
}
public class AQA
{
public int books { get; set; }
public float min { get; set; }
public float max { get; set; }
public float fee { get; set; }
}
我会尽量避免数百类声明的,因为所有的类都是除了 他们的名字一样。
我试图序列化这个数组或列表,但我得到异常,因为这不是一个数组。
我使用Newtonsoft JSON库。
谢谢
是的,它解决了我的问题。非常感谢你 – hkhk
不客气:) – uyquoc