using Newtonsoft.Json;
using System.Text;
namespace Znyc.Recruitment.Admin.Commons.Helpers
{
///
/// byte转换类
///
public class ByteConvertHelper
{
///
/// 将对象转换为byte数组
///
/// 被转换对象
/// 转换后byte数组
public static byte[] Object2Bytes(object obj)
{
string json = JsonConvert.SerializeObject(obj);
byte[] serializedResult = Encoding.UTF8.GetBytes(json);
return serializedResult;
}
///
/// 将byte数组转换成对象
///
/// 被转换byte数组
/// 转换完成后的对象
public static object Bytes2Object(byte[] buff)
{
string json = Encoding.UTF8.GetString(buff);
return JsonConvert.DeserializeObject