我试图使用RestSharp来反序列化不包含属性名称的json数据。返回的数据的顺序和类型与基于请求参数的预定义顺序匹配。
以下是响应数据的样子:
{
"pos": 0,
"start": 0,
"totalRecords": 2,
"data": [
[
"bdb4b591-482e-43a5-86c8-00c9e4b913df",
null,
null,
"SOUTH LAWN",
0,
300,
"fffde79d-68b2-4825-aaac-9be4d03e7d13",
true,
"2014-07-01T17:33:37.727",
1
],
[
"4980578e-5663-44c3-aed3-0151b085dc11",
"125",
"POLICE ACADEMY #",
"125",
634,
32,
"f6439406-6c74-455d-9d70-7540b514c651",
true,
"2014-12-04T14:50:37.707",
3
]
]}
这是代表数据项的DTO类:
public class RoomEntity
{
public string Id { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string RoomNumber { get; set; }
public float SquareFootage { get; set; }
public int MaxOccupancy { get; set; }
public string BuildingId { get; set; }
public bool IsActive { get; set; }
public DateTime ModifiedDate { get; set; }
public int RowVersion { get; set; }
}
public class QueryResponse<TEntity>
{
public int Pos { get; set; }
public int Start { get; set; }
public int TotalRecords { get; set; }
public List<TEntity> Data { get; set; }
}
我的客户执行:
var client = new RestClient() { BaseUrl = new Uri(BaseUrl), Timeout = Timeout };
var response = client.Execute<QueryResponse<RoomEntity>>(request);
我从restsharp收到此错误:
无法投射类型&#39; RestSharp.JsonArray&#39;键入&#39; System.Collections.Generic.IDictionary`2 [System.String,System.Object]&#39;。