json接收后无法反序列化
"{\"total\": \"1\", \"page\": \"1\", \"records\": \"1\", \"rows\": [{\"id\":\"1000\",\"cMonitorAreaName\":\"天麻监测\",\"cMonitorAreaDesc\":\"湿度监测\",\"iParentMonitorAreaid\":\"1\",\"iPlantFieldId\":\"30\",\"cPlantFieldName\":\"tuty\",\"id_NodeId\":\"100\",\"iIotNodeTypeId\":\"101\",\"iMonitorAreaId\":\"1000\",\"cIotNodeName\":\"test\",\"NodeNetworkNo\":\"111\",\"NodeHostNo\":\"112\",\"NodeRemark\":\"gfsdg\",\"HistoryDataId\":\"1\",\"fMonitorDataValue\":\"456.0\",\"dMonitorDateTime\":\"2013-07-26 05:00:00.0\",\"HistoryNodeNetworkNo\":\"123\",\"HistoryNodeHostNo\":\"12\",\"iParameterTypeId\":\"99\",\"cParameterTypeName\":\"tweta\",\"cParameterTypeDesc\":\"tretsr\",\"iValueType\":\"2\",\"cSymbol\":\"df\",\"cIotNodeTypeName\":\"ttt\",\"cIotNodeTypeDesc\":\"tttttt\",\"NodeTypeRemark\":\"tttt\"}"
以上是传来的JSON,我是用如下方法解析的
public static T parse<T>(string jsonstring)
{
try
{
using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(jsonstring)))
{
return (T)new DataContractJsonSerializer(typeof(T)).ReadObject(ms);
}
}
catch (Exception e) { return default(T); }
}
对于其他的json报文都可以解析,但是这个比较的串不行,错误是:{"反序列化对象 属于类型 iotmon_wpf.json.jsontext`1[[iotmon_wpf.IotDec.ViewDect+NodeAreaView, iotmon_wpf, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] 时出现错误。未正确格式化输入源。"}System.Exception {System.Runtime.Serialization.SerializationException}
请各位指教 JSON 异常 反序列化
[解决办法]
我一般用 Newtonsoft.Json.dll ,你可以试试,不过分版本
[解决办法]
\"rows\": [{
但是 没有封闭啊
:\"tttt\"}"