Error when deserializing JSON to Object

前端 未结 7 2001
别跟我提以往
别跟我提以往 2020-12-18 04:29

I need to convert JSON data that I get from a REST API and convert them to CSV for some analytic. The problem is that the JSON data do not necessarily follow the same conten

相关标签:
7条回答
  • 2020-12-18 05:11

    Try using this class instead of Object

    public class Datum
    {
        public string ID { get; set; }
        public string name { get; set; }
        public string objCode { get; set; }
        public double percentComplete { get; set; }
        public string plannedCompletionDate { get; set; }
        public string plannedStartDate { get; set; }
        public int priority { get; set; }
        public string projectedCompletionDate { get; set; }
        public string status { get; set; }
    }
    
    public class RootObject
    {
        public List<Datum> data { get; set; }
    }
    

    Change to this:

    var data = JsonConvert.DeserializeObject<RootObject>(jsonData);
    
    0 讨论(0)
提交回复
热议问题