Error when deserializing JSON to Object

前端 未结 7 2117
别跟我提以往
别跟我提以往 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 04:44

    You are trying to deserialize into a List but your JSON actually represents a single object containing a data property containing list of objects. That is why you are getting this error. Json.Net can't deserialize a single object into a list.

    Please try this:Create a class which contain single property on datatype Object and pass this class for deserialization.

    class Parent
    {
        public object Data { get; set;}
    }
    

    Then deserialize like this:

    var output = JsonConvert.DeserializeObject(jsonData);
    

提交回复
热议问题