#region JSON数据相关 /// <summary> /// httcotext json数据写出 /// </summary> /// <param name="response">response</param> /// <param name="status">status</param> /// <param name="msg">msg</param> /// <param name="data">object</param> public static void WriteJson(HttpResponse response, bool isOK, string msg, string nextUrl = null, object data = null) { response.ContentType = "application/json"; var obj = new { IsOK = isOK, Msg = msg, NextUrl = nextUrl, Data = data }; string json = new JavaScriptSerializer().Serialize(obj); response.Write(json); } /// <summary> /// 简单json数据写出 /// </summary> /// <param name="response">response</param> /// <param name="data">object</param> public static void WriteSimpleJson(HttpResponseBase response, object data = null) { response.ContentType = "application/json"; string json = new JavaScriptSerializer().Serialize(data); response.Write(json); } /// <summary> /// 简单json数据返回为string /// </summary> public static string WriteSimpleJson(object data = null) { string json = new JavaScriptSerializer().Serialize(data); return json; } /// <summary> /// 简单json数据构造 /// </summary> /// <param name="isOK">服务器处理是否成功</param> /// <param name="msg">报错消息</param> /// <param name="nextUrl">下个要访问的地址</param> /// <param name="data">携带的额外信息</param> /// <returns>JSON格式字符串</returns> public static ActionResult GetJsonResult(bool isOK, string msg, string nextUrl = null, object data = null) { return new JsonResult { Data = new { IsOK = isOK, Msg = msg, NextUrl = nextUrl, Data = data }, JsonRequestBehavior = JsonRequestBehavior.AllowGet }; } /// <summary> /// .net转为json序列化 /// </summary> /// <param name="obj"></param> /// <returns>dynamic obj</returns> public static dynamic ToDynamic(object obj = null) { string json = JsonConvert.SerializeObject(obj);//把.net转为json字符串 dynamic dyobj = JsonConvert.DeserializeObject(json);//把json字符串反序列化为.net对象 return dyobj; }
一片空白 5.8万
父爱如山,不善表达。回想十多年前,总记得父亲有个宽厚的肩膀,小小的自己跨坐在上面,越过人山人海去看更广阔的天空,那个时候期望自己有一双翅膀,能够像鸟儿一样飞得高,看得远。虽然父亲有时会和自己开玩笑,但在做错事的时候会受到严厉的训斥。父亲有双粗糙的大手掌。