JsonSerializerOptions.IgnoreNullValues Property

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Caution

JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.

Gets or sets a value that indicates whether null values are ignored during serialization and deserialization. The default value is false.

C#
[System.Obsolete("JsonSerializerOptions.IgnoreNullValues is obsolete. To ignore null values when serializing, set DefaultIgnoreCondition to JsonIgnoreCondition.WhenWritingNull.", DiagnosticId="SYSLIB0020", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public bool IgnoreNullValues { get; set; }
C#
public bool IgnoreNullValues { get; set; }

Property Value

true if null values are ignored during serialization and deserialization; otherwise, false.

Attributes

Exceptions

This property was set after serialization or deserialization has occurred.

-or-

DefaultIgnoreCondition has been set to a non-default value. These properties cannot be used together.

Remarks

For more information, see How to ignore properties.

Applies to

Product Versions (Obsolete)
.NET Core 3.0, Core 3.1, 5 (6, 7, 8 (package-provided), 8, 9 (package-provided), 9, 10 (package-provided), 10)
.NET Standard 2.0 (package-provided)