12345678910111213141516171819202122232425262728 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using Newtonsoft.Json;
- namespace cuidian.Common
- {
- public class JsonUtils
- {
- /// <summary>
- /// 返回格式化的json字符
- /// </summary>
- /// <param name="obj"></param>
- /// <returns></returns>
- public static string GetJsonString(object obj)
- {
- var jsonSetting = new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore };
- string s = JsonConvert.SerializeObject(obj, Formatting.Indented, jsonSetting);
- return s;
- }
- }
- }
|