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();

            });

 

posted @ 2022-04-19 09:49  猴猴手记  阅读(852)  评论(0编辑  收藏  举报
浏览器标题切换
浏览器标题切换end