Net Core中webapi接口返回结果json化
一、首先在Net Core中接口返回结果json化需要在Startup配置类中ConfigureServices方法中配置服务设置
services.AddControllers( ).AddNewtonsoftJson(options => { //忽略循环引用 options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //设置时间格式 options.SerializerSettings.DateFormatString = "yyyy-MM-dd HH:mm:ss"; // options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); });