12345678910111213141516171819202122232425262728 |
- using Newtonsoft.Json;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.Encodings.Web;
- using System.Text.Json;
- using System.Text.Json.Serialization;
- using System.Text.Unicode;
- using System.Threading.Tasks;
- public static class ObjectExtensions
- {
- /// <summary>
- /// 使用Newtonsoft Json将object转换为Json字符串
- /// </summary>
- /// <param name="this"></param>
- /// <returns></returns>
- public static string ToJson(this object @this)
- {
- JsonSerializerSettings jsonSettings = new JsonSerializerSettings
- {
- DateFormatString = "yyyy-MM-dd HH:mm:ss",
- };
- var str = Newtonsoft.Json.JsonConvert.SerializeObject(@this, jsonSettings);
- return str;
- }
- }
|