首页 > Windows开发 > 详细

C# JsonAdpater json 处理类

时间:2016-06-03 17:24:07      阅读:161      评论:0      收藏:0      [点我收藏+]
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 处理类

原文:http://www.cnblogs.com/BungeeJumping/p/5556929.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!