C# JsonAdpater json 处理类
Posted If_1989
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了C# JsonAdpater json 处理类相关的知识,希望对你有一定的参考价值。
public static class JsonAdapter<T> where T : class { public static string ToJson(T obj) { return JsonAdapter.ToJson(obj); } } public static class JsonAdapter { public static string ToJson(object o) { string result = ""; if (o != null) { javascriptSerializer serializer = new JavaScriptSerializer(); serializer.MaxJsonLength = serializer.MaxJsonLength * 100; result = serializer.Serialize(o); } return result; } public static object FromJsonAsDictionary(string jsonstr) { JavaScriptSerializer serializer = new JavaScriptSerializer(); serializer.MaxJsonLength = serializer.MaxJsonLength * 100; if (jsonstr == null) jsonstr = ""; return serializer.DeserializeObject(jsonstr) ?? new StringObjectDictionary(); } }
以上是关于C# JsonAdpater json 处理类的主要内容,如果未能解决你的问题,请参考以下文章