ste*_*evo 9 c# json json.net .net-core system.text.json
我正在从 .NET Core 3.0 应用程序迁移Newtonsoft.Json到System.Text.Json.NET Core 3.0 应用程序。
如何获得与配置System.Text.Json为 .NET Core 2.2 应用程序时相同的行为?您可以找到此处描述的选项。Newtonsoft.JsonDefaultValueHandling = DefaultValueHandling.IgnoreDefaultValueHandling
小智 2
我认为这会有所帮助
services.AddMvc().AddJsonOptions(options => options.JsonSerializerOptions.IgnoreNullValues = true);
Run Code Online (Sandbox Code Playgroud)