安装 Microsoft.AspNetCore.Mvc.Newtonsoft 包
在startup.cs中添加
public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddMvcCore().AddNewtonsoftJson(options => { options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; }); RegisterMyServices(services); }