/// <summary> /// 转换成JSON字符串 /// </summary> /// <param name="jsonObject"></param> /// <returns></returns> public static string stringify(object jsonObject) { try { using (var ms = new MemoryStream()) { new DataContractJsonSerializer(jsonObject.GetType()).WriteObject(ms, jsonObject); return Encoding.UTF8.GetString(ms.ToArray()); } } catch (Exception E) { Log4Net.Error("转换JSON字符串异常 : " + E.Message); return string.Empty; } }
using System.Runtime.Serialization.Json;