用JavaScriptSerializer().Deserialize解析字符串时遇到某个数组包含null该如何处理呢
要解析的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 转换为值类型。
不知道该如何处理 求大神告知