JsonSerializerOptions.RespectNullableAnnotations 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.
Gets or sets a value that indicates whether nullability annotations should be respected during serialization and deserialization.
public:
property bool RespectNullableAnnotations { bool get(); void set(bool value); };
public bool RespectNullableAnnotations { get; set; }
member this.RespectNullableAnnotations : bool with get, set
Public Property RespectNullableAnnotations As Boolean
Property Value
Exceptions
Thrown if this property is set after serialization or deserialization has occurred.
Remarks
Nullability annotations are resolved from the properties, fields and constructor parameters
that are used by the serializer. This includes annotations stemming from attributes such as
NotNullAttribute, MaybeNullAttribute,
AllowNullAttribute and DisallowNullAttribute.
Due to restrictions in how nullable reference types are represented at run time,
this setting only governs nullability annotations of non-generic properties and fields.
It cannot be used to enforce nullability annotations of root-level types or generic parameters.
The default setting for this property can be toggled application-wide using the
"System.Text.Json.Serialization.RespectNullableAnnotationsDefault" feature switch.
Applies to
Σχόλια
https://aka.ms/ContentUserFeedback.
Σύντομα διαθέσιμα: Καθ' όλη τη διάρκεια του 2024 θα καταργήσουμε σταδιακά τα ζητήματα GitHub ως μηχανισμό ανάδρασης για το περιεχόμενο και θα το αντικαταστήσουμε με ένα νέο σύστημα ανάδρασης. Για περισσότερες πληροφορίες, ανατρέξτε στο θέμα:Υποβολή και προβολή σχολίων για