JsonSerializerOptions.IgnoreReadOnlyProperties Property

Definition

Gets or sets a value that indicates whether read-only properties are ignored during serialization. The default value is false.

C#
public bool IgnoreReadOnlyProperties { get; set; }

Property Value

true if read-only properties are ignored during serialization; otherwise, false.

Exceptions

This property was set after serialization or deserialization has occurred.

Remarks

A property is read-only if it contains a public getter but not a public setter.

Read-only properties are not deserialized regardless of this setting.

For more information, see How to ignore properties with System.Text.Json.

Applies to

Produkt Versioner
.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)