标签:result str OLE 类型 pre name class close 报错
方法(依赖于Newtonsoft.Json):
/// <summary> /// 反序列化json字符串 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jsonText"></param> /// <returns></returns> public static T FromJson<T>(string jsonText) { var json = new JsonSerializer { NullValueHandling = NullValueHandling.Ignore, ObjectCreationHandling = ObjectCreationHandling.Replace, MissingMemberHandling = MissingMemberHandling.Ignore, ReferenceLoopHandling = ReferenceLoopHandling.Ignore }; var sr = new StringReader(jsonText); var reader = new JsonTextReader(sr); var result = (T)json.Deserialize(reader, typeof(T)); reader.Close(); return result; }
string jsonData = "{\"column\":\"1\"}";//,\"rows\":\"4\" dynamic jsonObj = JsonHelper.FromJson<dynamic>(jsonData); string rows = jsonObj.rows;//不会报错 结果为null Console.WriteLine(rows); Console.ReadKey();
标签:result str OLE 类型 pre name class close 报错
原文地址:https://www.cnblogs.com/zhyue93/p/json_Deserialize.html