using Newtonsoft.Json;
using System.Text;
namespace Admin.Core.Common
{
public class SerializeHelper
{
///
/// 序列化
///
///
///
public static byte[] Serialize(object item)
{
var jsonString = JsonConvert.SerializeObject(item);
return Encoding.UTF8.GetBytes(jsonString);
}
///
/// 反序列化
///
///
///
///
public static TEntity Deserialize(byte[] value)
{
if (value == null)
{
return default(TEntity);
}
var jsonString = Encoding.UTF8.GetString(value);
return JsonConvert.DeserializeObject(jsonString);
}
}
}