Files
Yi.Admin/CC.Yi.Old/CC.Yi.Common/JsonHelper.cs

25 lines
944 B
C#
Raw Normal View History

2021-05-13 01:39:34 +08:00
using System;
namespace CC.Yi.Common
{
public static class JsonHelper
{
2021-05-31 21:41:27 +08:00
public static string JsonToString(object data=null, int code = 200, bool flag = true, string message = "成功")
2021-05-13 01:39:34 +08:00
{
return Newtonsoft.Json.JsonConvert.SerializeObject(new { code = code, flag = flag, message = message, data = data });
}
2021-05-31 21:41:27 +08:00
public static string JsonToString2(object data = null, int code = 200, bool flag = true, string message = "成功",int count=0)
2021-05-13 01:39:34 +08:00
{
2021-05-31 21:41:27 +08:00
return Newtonsoft.Json.JsonConvert.SerializeObject(new { code = code, flag = flag, message = message, count=count,data = data });
2021-05-13 01:39:34 +08:00
}
public static string ToString(object data)
{
return Newtonsoft.Json.JsonConvert.SerializeObject(data);
}
public static T ToJson<T>(string data)
{
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(data);
}
}
}