任何使用Newtonsoft.Json将JSON数组反序列化为对象的方法

时间:2017-10-13 06:52:24

标签: c# arrays json json.net

我想使用Newtonsoft将JSON数组反序列化为类。

JSON数组(Api返回)

[1,"1",true,2,3]

上课

class MyObject {
    public int Number { get; set; }
    public string Data { get; set; }
    public bool IsIt { get; set; }
}

除了创建像

这样的构造函数之外,还有什么办法吗?
public MyObject(object[] array) {
    Number = (int)array[0];
    Data = (string)array[1];
    IsIt = (bool)array[2];
}

0 个答案:

没有答案