NetBlog主题

C#  Newtonsoft.Json 序列化指定 时间格式字符串
C#基础

C# Newtonsoft.Json 序列化指定 时间格式字符串

4361

在用 JsonConvert.SerializeObject(T) 时,序列化 的时间格式为 2020-05-30T15:47:13 而我们想要的格式为2020-05-30 15:47:13,实现核心代码如下public class TestModel {public int id { get; set; }public DateTime dateTime { get; set; } } 引用 using Newtonsoft.Json;…