2015-05-07 56 views
0

出於某種原因,沒有錯誤,RestSharp中的JsonSerializer未序列化以下數據。JSON數組未序列化

返回的對象具有除Calls數組爲空的所有數據。 參見輸出:http://puu.sh/hCsy9/5353cd7e02.png

{ 「api_id」: 「c7b1346a-f345-11e4-9335-22000ac50cb2」, 「元」:{ 「限制」:20, 「下一個」:「/ V1 /帳戶?/ MAOTAWNJFHYZM5NTA5ZD /呼叫/限制= 20 &偏移量= 20" , 「偏移」:0, 「先前」:空, 「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」:空, 「parent_call_uuid」: 「57b02c7e-f337-11e4-A957-ff7e66a0ec10」, 「resource_uri」: 「/ V1 /帳號/ MAOTAWNJFHYZM5NTA5ZD /電話/ 582fcfe2-f337-11e4-a997-ff7e66a0ec10 /」, 「TO_NUMBER」: 「17168072289」, 「TOTAL_AMOUNT」: 「0.01200」, 「Total_Rate的」:「 0.01200" },{ 「bill_duration」:10, 「billed_duration」:60, 「call_direction」: 「入站」, 「call_duration」:10, 「call_uuid」:「57b02c7e-f337-11e4-A957 -ff7e66a0ec10「, 」end_time「:」2015-05-05 10:59 :59-04:00「, 」from_number「:」sip:[email protected]「, 」parent_call_uuid「:null, 」resource_uri「:」/ v1/Account/MAOTAWNJFHYZM5NTA5ZD/Call/57b02c7e-f337-11e4 -a957-ff7e66a0ec10 /」, 「TO_NUMBER」: 「SIP:[email protected]」, 「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

嘗試使用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; } 
} 
+0

對不起,它沒有工作,仍然爲空。 –

+0

你能告訴我代碼,你是如何調用請求的? –