我正在尝试显示一个json数组,该数组是通过使用Web服务获得的,该Web服务返回的ResourceRequests列表包含DateTime类型的属性'dateDepot',但与Date
类型不同,它无法工作很好
我的实体:
public class ResourceRequestViewModel
{
[Key]
public int requestId { get; set; }
[StringLength(255)]
public string Director { get; set; }
[StringLength(255)]
public string EducationScolarity { get; set; }
[StringLength(255)]
public string Title { get; set; }
public DateTime depotDate { get; set; }
}
我的观点:
@foreach (var item in ViewBag.result)
{
<tr>
<td>
@item.requestId
</td>
<td>
@item.Director
</td>
<td>
@item.depotDate
</td>
</tr>
}
我的控制器:
public ActionResult Index()
{
List<ResourceRequestViewModel> liste = new List<ResourceRequestViewModel>();
HttpClient Client = new HttpClient();
Client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
HttpResponseMessage response = Client.GetAsync("http://localhost:18080/InfinityMAP-web/rest/ResourceRequestService/getResourceRequest").Result;
if (response.IsSuccessStatusCode)
{
ViewBag.result= response.Content.ReadAsAsync<List<ResourceRequestViewModel>>().Result;
}
else
{
ViewBag.result ="ERRORRR";
}
return View();
}
Web服务的我的Json输出:
[
{
"requestId": 1,
"client": {
"id": 1,
"nom": null,
"ipAdress": null,
"logo": null,
"categorie": "client_prive",
"typeClient": "nouveau_client",
"etat": null
},
"listMandats": [],
"director": "Fadi Ben nejma",
"title": "Title1",
"educationScolarity": "Uni",
"depotDate": 1541026800000,
"depotHour": 12,
"mandateStartDate": "2018-10-30",
"mandateEndDate": null,
"requiremenets": "php angular html",
"searchedProfile": "Backend Developper",
"yearsOfExperience": 5,
"EducationScolarity": "Uni",
"project": {
"id": 1,
"statut": "projet_encours",
"name": "slim",
"nom": "aouadi",
"etat": "1",
"projetStartDate": "2018-10-01",
"projetEndDate": "2018-10-31"
},
"Director": "Fadi Ben nejma"
}
]
我得到的错误是:
读取日期错误。意外令牌:整数。路径“ [0] .depotDate”