using Newtonsoft.Json; using System.Text; namespace EntrustSettle.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); } } }