.net core api

.net core dynamic type as argument . 

3-1、在Net core3.0以后,微软移除了Newtonsoft.Json,而使用了System.Text.Json,所以依赖于Newtonsoft.Json的组件将不可用,需要安装 Microsoft.AspNetCore.Mvc.NewtonsoftJson 包

3-2、为Controllers添加NewtonsoftJson注册,在Startup.cs下
public void ConfigureServices(IServiceCollection services)
{
   services.AddControllers() .AddNewtonsoftJson();
}

   原因为程序无法正常解析该json,因为没有找到NewtonsoftJson包的依赖;关于微软为何要移除该包的依赖,主要是为了提升执行效率;System.Text.Json作为微软内置json处理,效率更高更快,但是目前大部分主流的包还是使用的NewtonsoftJson开发。

 

参见

https://my.oschina.net/u/4311595/blog/3290111/print

posted on 2020-07-28 08:46  developer1980  阅读(199)  评论(0)    收藏  举报

导航