Method ConfigureApiNullHandling
ConfigureApiNullHandling(JsonSerializerOptions)
Applies the null handling to the options and to the type info of their current type info resolvers (see ApiNullHandlingExtensions). It must be called after the options' contexts and other resolvers are added: resolvers added afterwards are not covered.
Declaration
public static JsonSerializerOptions ConfigureApiNullHandling(this JsonSerializerOptions options)
Parameters
| Type | Name | Description |
|---|---|---|
| JsonSerializerOptions | options | The options to configure. |
Returns
| Type | Description |
|---|---|
| JsonSerializerOptions | The options, so that calls can be chained. |
Remarks
Sets RespectNullableAnnotations and RespectRequiredConstructorParameters to true, and makes required members that are nullable optional in the type info that the options' resolvers provide.
Calling it again also covers the resolvers added since the last call. Type info that a source-generated context provides for its own options, such
as MyJsonContext.Default.MyType, is not affected.
Exceptions
| Type | Condition |
|---|---|
| InvalidOperationException | The options are read-only, or have no type info resolver. |