1 引用包Microsoft.AspNetCore.Mvc.NewtonsoftJson
2 代码
public void ConfigureServices(IServiceCollection services) { services.AddControllers(option => { option.Filters.Add(typeof(ExceptionFilter)); option.AllowEmptyInputInBodyModelBinding = true; }).AddJsonOptions(options => { options.JsonSerializerOptions.Encoder = JavaScriptEncoder.Create(UnicodeRanges.All); options.JsonSerializerOptions.PropertyNamingPolicy = null; }).AddNewtonsoftJson(options => { options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm"; }); }