I'm trying to use RestSharp to deserialize json data that doesn't include property names. The order and type of the data returned matches a pre-defined order based on the request parameters.
Here's what the response data looks like:
{
"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
]
]}
Here's the DTO class that represents the data items:
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; }
}
Here's my client execute:
var client = new RestClient() { BaseUrl = new Uri(BaseUrl), Timeout = Timeout };
var response = client.Execute<QueryResponse<RoomEntity>>(request);
I get this error from restsharp:
Unable to cast object of type 'RestSharp.JsonArray' to type 'System.Collections.Generic.IDictionary`2[System.String,System.Object]'.