I'm converting a big repo over to .net core and I'm having trouble finding a replacement for the [ScriptIgnore] attribute that used to be inside System.Web.Script.Serialization.
Is there a substitue for this attribute?
I'm converting a big repo over to .net core and I'm having trouble finding a replacement for the [ScriptIgnore] attribute that used to be inside System.Web.Script.Serialization.
Is there a substitue for this attribute?
You want System.Text.Json.Serialization.JsonIgnore, or (depending on your version of .NET) Newtonsoft's JsonIgnoreAttribute. [ScriptIgnore] (and the System.Web.Script.Serialization namespace) was discontinued in .NET Core and should only be used in legacy versions of .NET Framework.
System.Text.Json should be compatible with all versions of .NET after .NET Framework 4.7.2, but I haven't tested this:
For .NET Framework 4.7.2 and later versions, use the APIs in the System.Text.Json namespace for serialization and deserialization. For earlier versions of .NET Framework, use Newtonsoft.Json. This type was intended to provide serialization and deserialization functionality for AJAX-enabled applications.