【发布时间】:2020-02-02 04:48:51
【问题描述】:
我正在 .NET Core 3.0 应用程序中从 Newtonsoft.Json 迁移到 System.Text.Json。
我如何获得与System.Text.Json 相同的行为,就像我在配置Newtonsoft.Json 和DefaultValueHandling = DefaultValueHandling.Ignore 的.NET Core 2.2 应用程序中一样?您可以找到here 中描述的DefaultValueHandling 选项。
【问题讨论】:
-
您需要
System.ComponentModel.DefaultValueAttribute来确定属性是否具有默认值吗?如果没有,请参阅this answer 相关问题How to ignore false values with System.Text.Json。
标签: c# json .net-core json.net system.text.json