我想反序列化如下所示的模型列表:
public class GlobalSearchModel
{
public List<ProductionModel> ProductionOrder { get; set; }
public List<ItemModel> Item { get; set; }
public List<LayoutModel> Layout { get; set; }
}
我想在那做:
[HttpGet("[Action]")]
public async Task<IActionResult> Index([FromQuery]string code, bool layout, bool item, bool production)
{
HttpResponseMessage response = await _httpClient.GetAsync(string.Format("GlobalSearch?elementSearch={0}&itemBool={1}&layoutBool={2}&productionBool={3}", code, item, layout, production));
if (response.IsSuccessStatusCode)
{
string jsonString = await response.Content.ReadAsStringAsync();
List<GlobalSearchModel> search = JsonConvert.DeserializeObject<List<GlobalSearchModel>>(jsonString);
return Json(search);
}
else
return View();
}
但是Json回到我这里的是:
[{"productionOrder":null,"item":null,"layout":null}]
我在变量JsonString
上设置了一个断点,并且有响应,但是我不能使用它。
JsonString外观的返回是:
[{\"itemlist\":[{\"Id\":0,\"ItemCode\":\"1235\",\"ItemVariant\":null,\"Modified\":null,\"ModifiedBy\":null,\"ReasonId\":null,\"ReasonComment\":null,\"Type\":null}],\"productionlist\":[],\"LayoutsList\":[]}]