转化json

/// <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;
上一篇:Apache commons-codec笔记


下一篇:Java入门学习笔记