110,552
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
string json = "{\"response\":{\"errorCount\":2,\"totalCount\":2}}";
OrderResponse res = JsonConvert.DeserializeObject<OrderResponse>(json);
Console.WriteLine("ErrCount:{0}", res.ErrCount);
Console.WriteLine("TotalCount:{0}", res.TotalCount);
}
[DataContract(Name = "response")]
public class OrderResponse
{
[DataMember(Name = "errorCount")]
public int ErrCount { get; set; }
[DataMember(Name = "totalCount")]
public int TotalCount { get; set; }
}
public class OrderResponseWrapper
{
public OrderResponse response { get; set; }
}
[DataContract(Name = "response")]
public class OrderResponse
{
[DataMember(Name = "errorCount")]
public int ErrCount { get; set; }
[DataMember(Name = "totalCount")]
public int TotalCount { get; set; }
}
string json = "{\"response\":{\"errorCount\":2,\"totalCount\":2}}";
OrderResponseWrapper res = JsonConvert.DeserializeObject<OrderResponseWrapper>(json);
Console.WriteLine("ErrCount:{0}", res.response.ErrCount);
Console.WriteLine("TotalCount:{0}", res.response.TotalCount);