出于某种原因,没有错误,RestSharp中的JsonSerializer不会序列化以下数据。
返回的对象包含所有数据,但Calls数组为NULL。 请参阅输出:http://puu.sh/hCsy9/5353cd7e02.png
{" api_id":" c7b1346a-f345-11e4-9335-22000ac50cb2"," meta":{ "限制":20, " next":" / v1 / Account / MAOTAWNJFHYZM5NTA5ZD / Call /?limit = 20& offset = 20", "偏移":0, "之前":null, " total_count":3072},"对象":[ { " bill_duration":10, " billed_duration":60, " call_direction":" outbound", " call_duration":10, " call_uuid":" 582fcfe2-f337-11e4-a997-ff7e66a0ec10", " end_time":" 2015-05-05 10:59:59-04:00", " from_number":null, " parent_call_uuid":" 57b02c7e-f337-11e4-a957-ff7e66a0ec10", " resource_uri":" / v1 / Account / MAOTAWNJFHYZM5NTA5ZD / Call / 582fcfe2-f337-11e4-a997-ff7e66a0ec10 /", " to_number":" 17168072289", " total_amount":" 0.01200", " total_rate":" 0.01200" }, { " bill_duration":10, " billed_duration":60, " call_direction":" inbound", " call_duration":10, " call_uuid":" 57b02c7e-f337-11e4-a957-ff7e66a0ec10", " end_time":" 2015-05-05 10:59:59-04:00", " from_number":" sip:225@127.0.0.1", " parent_call_uuid":null, " resource_uri":" / v1 / Account / MAOTAWNJFHYZM5NTA5ZD / Call / 57b02c7e-f337-11e4-a957-ff7e66a0ec10 /", " to_number":" sip:elastix150502112926@phone.plivo.com", " total_amount":" 0.00300", " total_rate":" 0.00300" }]}
public class GetAllCallsResponse : PlivoResponse
{
[DataMember(Name = "meta")]
public GetAllCallsMeta Meta { get; set; }
[DataMember(Name = "objects")]
public List<datas> Calls { get; set; }
}
[DataContract]
public class datas
{
[DataMember]
public int bill_duration { get; set; }
[DataMember]
public int billed_duration { get; set; }
[DataMember]
public string call_direction { get; set; }
[DataMember]
public int call_duration { get; set; }
[DataMember]
public string call_uuid { get; set; }
[DataMember]
public string end_time { get; set; }
[DataMember]
public string from_number { get; set; }
[DataMember]
public string parent_call_uuid { get; set; }
[DataMember]
public string resource_uri { get; set; }
[DataMember]
public string to_number { get; set; }
[DataMember]
public string total_amount { get; set; }
[DataMember]
public string total_rate { get; set; }
}
答案 0 :(得分:0)
尝试使用DeserializeAs属性:
public class GetAllCallsResponse : PlivoResponse
{
[DeserializeAs(Name = "meta")]
public GetAllCallsMeta Meta { get; set; }
[DeserializeAs(Name = "objects")]
public List<datas> Calls { get; set; }
}
public class datas
{
[DeserializeAs(Name = "bill_duration")]
public int bill_duration { get; set; }
[DeserializeAs(Name = "billed_duration")]
public int billed_duration { get; set; }
[DeserializeAs(Name = "call_direction")]
public string call_direction { get; set; }
[DeserializeAs(Name = "call_duration")]
public int call_duration { get; set; }
[DeserializeAs(Name = "call_uuid")]
public string call_uuid { get; set; }
[DeserializeAs(Name = "end_time")]
public string end_time { get; set; }
[DeserializeAs(Name = "from_number")]
public string from_number { get; set; }
[DeserializeAs(Name = "parent_call_uuid")]
public string parent_call_uuid { get; set; }
[DeserializeAs(Name = "resource_uri")]
public string resource_uri { get; set; }
[DeserializeAs(Name = "to_number")]
public string to_number { get; set; }
[DeserializeAs(Name = "total_amount")]
public string total_amount { get; set; }
[DeserializeAs(Name = "total_rate")]
public string total_rate { get; set; }
}