ublic class SerializeHelper
{
/// <summary>
/// 序列化 实体->字符串
/// </summary>
/// <returns></returns>
public static string SerializeObject(object obj)
{
var str = JsonConvert.SerializeObject(obj);
return str;
}
/// <summary>
/// 反序列化 字符串->实体
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="str"></param>
/// <returns></returns>
public static T DeserializeObject<T>(string str) where T : class, new()
{
var obj = JsonConvert.DeserializeObject<T>(str);
return obj;
}
}