前台我们一般用ajax来发送数据到后端进行处理,如果json数据结构和后台的实体类结构一致,就直接可以反序列化为指定的对象进行操作,非常方便。

前端发送的json数据结构:


后端实体结构:

    public partial class Cures
    {
        public string CureID { get; set; }
        public string MainCureSubjectID { get; set; }
        public string MainCureSubjectName { get; set; }
        public string PatientID { get; set; }
        public string Symptom { get; set; }
        public string Diagnosis { get; set; }
        public string CompareID { get; set; }
        public string Therapy { get; set; }
        public string Draft { get; set; }
        public Nullable<System.DateTime> CureDate { get; set; }
        public Nullable<int> PrescriptionDosage { get; set; }
        public Nullable<decimal> Amount { get; set; }
        public string CureDocPath { get; set; }
        public Nullable<int> CureType { get; set; }
        public string Remark { get; set; }
    }

我这个是partial分部类,还有一些参数,保证json的参数在对应实体类里都有,就可以进行反序列化了。

Cures cure = Deserialize<Cures>(CureInfo);
CureInfo为接收到的json字符串,Deserialize是反序列化,如果是json数组,那么就反序列化为集合Deserialize<List<T>>了。



GitHub 加速计划 / js / json
41.72 K
6.61 K
下载
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e 2 个月前
8c391e04 5 个月前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐