【发布时间】:2019-03-04 05:08:57
【问题描述】:
我正在开发前端使用 Angular 7 开发的网站。我正在将一个数组从 json 格式的角度发送到 c#asp.net 核心。我正在获取以下格式的数据
`First = {"model": [{
"_organization_Name": "erw",
"_designation": "dfs",
"_p_Start_Date": "2019-02-28T19:00:00Z",
"_p_End_Date": "2019-03-27T19:00:00Z"
},
{
"_organization_Name": "erwfg",
"_designation": "dfsfgfg",
"_p_Start_Date": "2019-02-28T19:00:00Z",
"_p_End_Date": "2019-03-27T19:00:00Z"
}
]
}`
我在asp.net core下面的方法
[HttpPost("[action]")]
public IActionResult SaveProfessional([FromBody]JObject prof)
{
var obj = new Candidate_Professional_Info_Table(_context);
obj.Identity_Number = 112131.ToString();
obj =
JsonConvert.DeserializeObject<Candidate_Educational_Info_Table>(prof);
var result = obj.SaveProfessional(prof);
return Ok(new { suces = "result" });
}
我的代码没有反序列化 json 对象请提供任何解决方案,因为现在我已经在这个问题上花了一周时间。我的 c# 模型如下所示
public int ID { get; set; }
public string Identity_Number { get; set; }
[Required]
[RegularExpression("^[a-zA-Z0-9]+$", ErrorMessage = "Organization Name Not Valid")]
public string Organization_Name { get; set; }
[Required]
[RegularExpression("^/d{1, 2}///d{1,2}///d{4}$")]
public DateTime? p_Start_Date { get; set; }
[RegularExpression("^/d{1, 2}///d{1,2}///d{4}$")]
public DateTime? p_End_Date { get; set; }
[Required]
[RegularExpression("^[a-zA-Z0-9]+$", ErrorMessage = "Designation Name Not Valid")]
public string Designation { get; set; }
public bool InProgress { get; set; }
[NotMapped]
public List<Candidate_Professional_Info_Table> listprof { get; set; }
[NotMapped]
private readonly RegConnString _Context;
public Candidate_Professional_Info_Table(RegConnString connString)
{
_Context = connString;
}
【问题讨论】:
-
我可能错了,但看起来您的 JSON 对象与模型不匹配
标签: c# asp.net json angular angular7