回傳物件:
{
"_expands": [],
"size": 3,
"start": 3,
"limit": 3,
"isLastPage": false,
"_links": {
"base": "http://host:port/context/rest/desk",
"context": "context",
"next": "http://host:port/context/rest/desk",
"prev": "http://host:port/context/rest/desk"
},
"values": [
{
"status": "Waiting for Customer",
"statusDate": {
"iso8601": "2015-10-08T14:05:00 0700",
"polaris": "2015-10-08T14:05:00.000 0700",
"friendly": "Today 14:05 PM",
"epochMillis": 1444287900000
}
},
{
"status": "Waiting for Support",
"statusDate": {
"iso8601": "2015-10-08T14:01:00 0700",
"polaris": "2015-10-08T14:01:00.000 0700",
"friendly": "Today 14:01 PM",
"epochMillis": 1444287660000
}
},
{
"status": "Waiting for Customer",
"statusDate": {
"iso8601": "2015-10-08T14:00:00 0700",
"polaris": "2015-10-08T14:00:00.000 0700",
"friendly": "Today 14:00 PM",
"epochMillis": 1444287600000
}
}
]
}
課程:
public class polarisState
{
public string[] expands { get; set; }
public int size { get; set; }
public int start { get; set; }
public int limit { get; set; }
public bool isLastPage { get; set; }
public _links links { get; set; }
public values[] values { get; set; }
}
public class _links
{
//public string base {get; set;}
public string context { get; set; }
public string next { get; set; }
public string prev { get; set; }
}
public class values
{
public string status { get; set; }
public statusDate statusDate { get; set; }
}
public class statusDate
{
public string iso8601 { get; set; }
public string polaris { get; set; }
public string friendly { get; set; }
public int epochMillis { get; set; }
}
下面的代碼:
if (resp2.IsSuccessStatusCode)
{
var values = JsonConvert.DeserializeObject<JiraState>(resp2.Content.ReadAsStringAsync().Result); }
uj5u.com熱心網友回復:
您應該將 polarisState 類更改為
public class polarisState
{
public List<string> expands { get; set; }
public int size { get; set; }
public int start { get; set; }
public int limit { get; set; }
public bool isLastPage { get; set; }
public _links links { get; set; }
public List<values> values { get; set; }
}
陣列到串列。然后將 statusDate 更改為:
public class statusDate
{
public string iso8601 { get; set; }
public string polaris { get; set; }
public string friendly { get; set; }
public long epochMillis { get; set; }
}
將 epochMillis 從 int 更改為 long 值型別。完成。
使用 async 方法并更改代碼如下:
var content = await resp2.Content.ReadAsStringAsync();
var values = JsonConvert.DeserializeObject<polarisState>(content);
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/382183.html
