PROPERTY

JsonSerializerOptions.RespectRequiredConstructorParameters

When enabled, non-optional constructor parameters used for deserialization must be supplied in the JSON. This does not reject null for every reference parameter or validate business rules.

Formal Syntax & Structure

csharp syntaxcsharp
new JsonSerializerOptions { RespectRequiredConstructorParameters = true }

Working Example

Example Snippetcsharp
using System;using System.IO;using System.Collections.Generic;using System.Text.Json;var options = new JsonSerializerOptions { RespectRequiredConstructorParameters = true }; Console.WriteLine(options.RespectRequiredConstructorParameters); // True
C# & .NET Reference