我试图反序列化json数据但它显示的错误是这样的。
public ActionResult Test(Login Log)
{
string sStudName = "ram";
HttpClient client = new HttpClient();
client.BaseAddress = new Uri(StudentAPI);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // this depends on whether you want to get back json or XML
var loginResp = client.PostAsJsonAsync(StudentAPI, Log).Result;
if (loginResp.IsSuccessStatusCode)
{
//if (loginResp == null)
//{
var msg = loginResp.Content.ReadAsStringAsync();
obJson res = JsonConvert.DeserializeObject<obJson>(loginResp.Content.ReadAsStringAsync().Result);
return Json(Log, JsonRequestBehavior.AllowGet);
//}
//return Redirect("/Admission/Registration");
}
else
{
}
return View();
}
答案 0 :(得分:0)
看看this question(它指的是JSON.net)
所以在你的情况下你应该尝试(如果可以使用JSON.net)
var msg = ""; // Get json message as string
dynamic json = JObject.Parse(msg);
// Do something with this JSON