首页 新闻 会员 周边 捐助

json序列化 list里还有一个list,为什么第二个属性里全部为null?

0
[已解决问题] 解决于 2017-02-21 14:51

我有这样一个json字符串

[{"SessionId":"29066","TdpId":"11503","Version":"20170221120614","FromSystem":"Itap","RegistrationDataModels":[{"RegistrationID: ":"11328176","TestStatus: ":"2","ScoreStatus: ":"22","RejectedReason: ":"52","StageStatus: ":"0"},{"RegistrationID: ":"11371732","TestStatus: ":"2","ScoreStatus: ":"22","RejectedReason: ":"52","StageStatus: ":"0"},{"RegistrationID: ":"11374823","TestStatus: ":"2","ScoreStatus: ":"22","RejectedReason: ":"52","StageStatus: ":"0"},{"RegistrationID: ":"11382592","TestStatus: ":"5","ScoreStatus: ":"12","RejectedReason: ":"24","StageStatus: ":"0"}]}]

把它序列化为一个model

我的model是这样的

 public int SessionId { get; set; }
        public int TdpId { get; set; }
        public long Version { get; set; }
        public string FromSystem { get; set; }
        public List<RegistrationDataModel> RegistrationDataModels { get; set; }





[Serializable]
    public class RegistrationDataModel
    {
        public string RegistrationID { get; set; }
        public string TestStatus { get; set; }
        public string ScoreStatus { get; set; }
        public string RejectedReason { get; set; }
        public string StageStatus { get; set; }
        
    }

可是为什么序列化后的数据,在RegistrationDataModel中的属性都为 null?

我是这样序列化的

Newtonsoft.Json.JsonConvert.DeserializeObject<T>(json);

跪求,是我哪里写错了吗?

临冰听雪丶的主页 临冰听雪丶 | 初学一级 | 园豆:175
提问于:2017-02-21 14:06
< >
分享
最佳答案
0

是我json写错了。

临冰听雪丶 | 初学一级 |园豆:175 | 2017-02-21 14:51
其他回答(1)
0

是要

Newtonsoft.Json.JsonConvert.DeserializeObject<T[]>(json); 
吴瑞祥 | 园豆:29449 (高人七级) | 2017-02-21 14:31
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册