用JavaScriptSerializer().Deserialize解析字符串时遇到某个数组包含null该如何处理呢

Initial D Initial D 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
要解析的json字符串
{
"State":0,
"Datas":{
"1":{
"VarUnit":"m3",
"DataTimes":[
"2019-01-01 00:00:00",
"2019-02-01 00:00:00",
"2019-03-01 00:00:00",
"2019-04-01 00:00:00",
"2019-05-01 00:00:00"
],
"DataValues":[
2976,
2688,
2569,
18044.9,
null
]
}
}
}
解析后的对象结构
public class DataJson
{
public int State { get; set; }
public Dictionary<string, MeterData> Datas { get; set; }
}
public class MeterData
{

public string VarUnit { get; set; }

public List<string> DataTimes { get; set; }

public List<decimal> DataValues { get; set; }
}

出现的异常:
System.InvalidOperationException: 无法将 null 转换为值类型。
不知道该如何处理 求大神告知
...全文

相关推荐

评论 3
收藏 已收藏
分享
返回顶部
Initial D
.NET社区 62,272 成员 668,968 内容