【发布时间】:2020-02-18 07:30:37
【问题描述】:
我最近将我的 API 项目更新为 ASP.NET Core 3。从那时起,[JsonIgnore] 属性就不起作用了:
public class Diagnostico
{
[JsonIgnore]
public int TipoDiagnostico { get; set; }
[JsonIgnore]
public int Orden { get; set; }
[JsonIgnore]
public DateTime? FechaInicio { get; set; }
public string TipoCodificacion { get; set; }
public string Codigo { get; set; }
public string Descripcion { get; set; }
}
类的所有属性都被序列化了。 API 端点在 .NET Core 3 中,但所有逻辑都在 .NET Standard 2.1 中。我意识到序列化程序已从 Newtonsoft.Json 更改为
System.Text.Json。此包在 .NET Standard 2.1 中不可用(它仅适用于 .NET Core),因此要在我正在使用的 .NET Standard 项目中的模型中使用 [JsonIgnore] Newtonsoft.Json。
【问题讨论】:
标签: c# json asp.net-core json.net asp.net-core-3.0