我目前正致力于处理从api获得的数据的程序。但我找不到在项目列表后反序列化对象的方法。我正在使用Newtonsoft.JsonConvert来完成这项工作。
测试代码
struct Next
{
string href { get; set; }
}
public struct MetaInfo
{
int totalCount { get; set; }
public List<Order> items { get; set; }
Next next { get; set; }
int pageCount { get; set; }
}
public class Orders
{
public List<Order> items { get; set; }
public Orders()
{
items = new List<Order>();
}
}
public class Order
{
public bool buy { get; set; }
public DateTime issued { get; set; }
public decimal price { get; set; }
public int volume { get; set; }
public int duration { get; set; }
public ulong id { get; set; }
public int minVolume { get; set; }
public string range { get; set; }
public ulong stationID { get; set; }
public int type { get; set; }
public Order(bool buy, DateTime issued,decimal price,int volume,int duration,ulong id, int minVolume,string range,ulong stationID,int type)
{
this.buy = buy;
this.issued = issued;
this.price = price;
this.volume = volume;
this.duration = duration;
this.id = id;
this.minVolume = minVolume;
this.range = range;
this.stationID = stationID;
this.type = type;
}
}
}
我尝试反序列化的数据样本:
{"items": [{"buy": false, "issued": "2017-03-07T11:06:09", "price": 50000.0, "volume": 1, "duration": 365, "id": 911203054, "minVolume": 1, "volumeEntered": 1, "range": "region", "stationID": 60000274, "type": 967}, {"buy": false, "issued": "2017-03-28T11:23:16", "price": 50000.0, "volume": 1, "duration": 365, "id": 911203055, "minVolume": 1, "volumeEntered": 1, "range": "region", "stationID": 60000277, "type": 967}], "totalCount": 280705, "previous": {"href": "https://crest-tq.eveonline.com/market/10000002/orders/all/"}, "next": {"href": "https://crest-tq.eveonline.com/market/10000002/orders/all/?page=3"}, "pageCount": 10}
答案 0 :(得分:0)
曾几何时,我遇到了同样的问题。
然后我找到了这个工具:this
使用这些类
public class Item
{
public bool buy { get; set; }
public string issued { get; set; }
public double price { get; set; }
public int volume { get; set; }
public int duration { get; set; }
public int id { get; set; }
public int minVolume { get; set; }
public int volumeEntered { get; set; }
public string range { get; set; }
public int stationID { get; set; }
public int type { get; set; }
}
public class Previous
{
public string href { get; set; }
}
public class Next
{
public string href { get; set; }
}
public class RootObject
{
public List<Item> items { get; set; }
public int totalCount { get; set; }
public Previous previous { get; set; }
public Next next { get; set; }
public int pageCount { get; set; }
}
快乐编码:)