[英]Problems Deserialising a nested object array
Here are my models:这是我的模型:
public class Order
{
public IEnumerable<LineItem> LineItems { get; set; }
}
Try this using Newtonsoft.Json尝试使用 Newtonsoft.Json
using Newtonsoft.Json;
.....
public List<Order> GetOrdersJson()
{
var result = _httpRequestService.CallApi(_url).Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject< List<Order>>(result.Result);
}
IEnumerable<T><\/code> is not a valid type for the serializer.
IEnumerable<T><\/code>不是序列化程序的有效类型。
It doesn't define any concrete implementation of a collection for the serializer to parse the JSON into.
它没有为序列化程序定义任何具体的集合实现来将 JSON 解析为。 Use
List<T><\/code> when deserializing JSON arrays.
反序列化 JSON 数组时使用
List<T><\/code> 。
"
public List<Order> GetOrdersJson()
{
var result = _httpRequestService.CallApi(_url).Content.ReadAsStringAsync();
return _httpRequestService.DeserializeApiResponseJson<Order>(result.Result);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.