1、需要安装两个包
Newtonsoft.Json
Microsoft.AspNetCore.Mvc.NewtonsoftJson
2、 Startup 类中的 ConfigureServices 方法插入如下代码
public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); }