我有一个 JSON 字符串(根据验证器)是有效的 JSON,我一直试图将其解析为 c# 中的对象。
示例字符串:
{"asks":[["49999.99000","20.00000000"],["900.00000","4.00000000"],["100.00000","5.00000000"]],"bids":[["5.40000","15.06500000"],["5.53675","0.50000000"],["5.00000","6.00000000"]]}
我曾尝试使用http://json2csharp.com/它建议这个类(它确实有效):
public class RootObject
{
public List<List<string>> asks { get; set; }
public List<List<string>> bids { get; set; }
}
但是我想像List<Ask> asks { get; set; }
. 我尝试了以下方法:
public class Orderbook
{
public List<Ask> asks { get; set; }
public List<Bid> bids { get; set; }
}
public class Ask
{
public double amount { get; set; }
public double price { get; set; }
}
public class Bid
{
public double amount { get; set; }
public double price { get; set; }
}
但这会失败,因为类型'namespace.Ask'不支持数组的反序列化。