我在这里遗漏了一些明显的东西吗?JSON:
{"p":[{},{"clientId":102102059663,"checkbox1Ticked":false,"checkbox2Ticked":false},{"clientId":23841,"checkbox1Ticked":false,"checkbox2Ticked":false},{ "clientId":102102111426,"checkbox1Ticked":false,"checkbox2Ticked":false}]}
C#:(checkboxData 是上面的字符串)
public JsonResult SubmitSelectedChanges(string checkboxData)
{
var deserializedClients = JsonConvert.DeserializeObject<ChangeList>(checkboxData);
return null;
}
public class ChangeList
{
public List<Change> p { get; set; }
}
public class Change
{
string clientId { get; set; }
bool checkbox1Ticked { get; set; }
bool checkbox2Ticked { get; set; }
}
反序列化后,clientId 始终为 null,并且 checbox1Ticked 和 checkbox2Ticked 为 false。