如何解决解析对C#对象的Json响应时,请跳过Nullable int
我正在解析对c#对象的json响应
我的模型
public class OutstandingPrompts
{
public int? PatientID { get; set; }
public int? AlertTypeID { get; set; }
public int? PatientAlertID { get; set; }
public int? PriorityID { get; set; }
public string PriorityColor { get; set; }
public string Priority { get; set; }
public string AlertType { get; set; }
public DateTime? RecallDate { get; set; }
public string ForSmoking { get; set; }
public string Note { get; set; }
public string AlertValue { get; set; }
public string AlertGroup { get; set; }
public DateTime? EXPIRYDATE { get; set; }
public string FullName { get; set; }
public string ProviderName { get; set; }
public int? AlertCategory { get; set; }
public int? IsConfidential { get; set; }
public int? ConfidentialViewLogID { get; set; }
public int? Completed { get; set; }
public int? TotalRecords { get; set; }
}
这就是我的转换方式
List<OutstandingPrompts> b = xs.Value.ElementAt(0).ElementAt(0).ToObject<List<OutstandingPrompts>>();
和它工作正常,因为我在模型中将int类型设置为可为null的int?因为int类型可能存在null值
现在我在想什么,有没有办法在不将我的int类型设置为可空的情况下解析json 。我知道的一种方法是在检查结果为空时循环遍历它,然后不分配值,但是有没有另一种不用编写自己的逻辑的方法?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。