C# 如何将列表对象转换为client.PostAsJsonAsync

C# 如何将列表对象转换为client.PostAsJsonAsync,c#,asp.net-mvc,C#,Asp.net Mvc,如何将列表对象转换为client.PostAsJsonAsync 类模型 public class CheckStatusModel { public int OBJID { get; set; } public string SUPID { get; set; } public string STATUSPTC { get; set; } public int DATEACTIVESUP { get; set; } } public class Check

如何将列表对象转换为client.PostAsJsonAsync

类模型

public class CheckStatusModel
{
    public int OBJID { get; set; }
    public string SUPID { get; set; }
    public string STATUSPTC { get; set; }  
    public int DATEACTIVESUP { get; set; }
}

public class CheckStatus
{
    public CheckStatusModel Data { get; set; }
    public string StatusCode { get; set; }
}
使用发送查找web api REST服务资源的请求
HttpClient**

using (var client = new HttpClient())
{
     client.BaseAddress = new Uri(Baseurl);
     client.DefaultRequestHeaders.Clear();
     client.DefaultRequestHeaders.Accept.Add(new 
     MediaTypeWithQualityHeaderValue("application/json"));
     HttpResponseMessage response = await client.PostAsJsonAsync("api/RPDeployment/BIL_CFP_BOX_CHECK_STATUSPTC", checkStatusParam);
     if(response.IsSuccessStatusCode)
       {
            var EmpResponse = response.Content.ReadAsStringAsync().Result;
            ListStatusPTC = JsonConvert.DeserializeObject<List<CheckStatus>>(EmpResponse);// not convert ????

       }
 }

请帮帮我???

哦,我明白了。您正在尝试将对象(由
{
}
表示)反序列化到列表中(在JSON中,由
[
]
表示)

您需要按如下方式更改
CheckStatus
类:

public class CheckStatus
{
    public List<CheckStatusModel> Data { get; set; } // data is an array so this needs to be some kind of collection
    public string StatusCode { get; set; }
}
公共类检查状态
{
公共列表数据{get;set;}//Data是一个数组,因此需要某种类型的集合
公共字符串状态码{get;set;}
}
并反序列化如下:

ListStatusPTC = JsonConvert.DeserializeObject<CheckStatus>(EmpResponse); // the JSON contains an object, so this needs to deserialize to an object. you can't deserialize to a list.
ListStatusPTC=JsonConvert.DeserializeObject(EmpResponse);//JSON包含一个对象,因此需要反序列化为一个对象。无法反序列化到列表。
ListStatusPTC = JsonConvert.DeserializeObject<CheckStatus>(EmpResponse); // the JSON contains an object, so this needs to deserialize to an object. you can't deserialize to a list.