<PackageReference Include="System.Text.Json" Version="9.0.0-rc.1.24431.7" />

JsonSerializerOptions

public sealed class JsonSerializerOptions
Provides options to be used with JsonSerializer.
public static JsonSerializerOptions Default { get; }

Gets a read-only, singleton instance of JsonSerializerOptions that uses the default configuration.

public static JsonSerializerOptions Web { get; }

public bool AllowOutOfOrderMetadataProperties { get; set; }

public bool AllowTrailingCommas { get; set; }

Get or sets a value that indicates whether an extra comma at the end of a list of JSON values in an object or array is allowed (and ignored) within the JSON payload being deserialized.

public IList<JsonConverter> Converters { get; }

Gets the list of user-defined converters that were registered.

public int DefaultBufferSize { get; set; }

Gets or sets the default buffer size, in bytes, to use when creating temporary buffers.

Gets or sets a value that determines when properties with default values are ignored during serialization or deserialization. The default value is Never.

Gets or sets the policy used to convert a IDictionary key's name to another format, such as camel-casing.

public JavaScriptEncoder Encoder { get; set; }

Gets or sets the encoder to use when escaping strings, or null to use the default encoder.

public bool IgnoreNullValues { get; set; }

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

public bool IgnoreReadOnlyFields { get; set; }

Gets or sets a value that indicates whether read-only fields are ignored during serialization. A field is read-only if it is marked with the readonly keyword. The default value is false.

public bool IgnoreReadOnlyProperties { get; set; }

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

public bool IncludeFields { get; set; }

Gets or sets a value that indicates whether fields are handled during serialization and deserialization. The default value is false.

public char IndentCharacter { get; set; }

public int IndentSize { get; set; }

public bool IsReadOnly { get; }

Gets a value that indicates whether the current instance has been locked for user modification.

public int MaxDepth { get; set; }

Gets or sets the maximum depth allowed when serializing or deserializing JSON, with the default value of 0 indicating a maximum depth of 64.

public string NewLine { get; set; }

public JsonNumberHandling NumberHandling { get; set; }

Gets or sets an object that specifies how number types should be handled when serializing or deserializing.

Gets or sets the preferred object creation handling for properties when deserializing JSON.

public bool PropertyNameCaseInsensitive { get; set; }

Gets or sets a value that indicates whether a property's name uses a case-insensitive comparison during deserialization. The default value is false.

Gets or sets a value that specifies the policy used to convert a property's name on an object to another format, such as camel-casing, or null to leave property names unchanged.

Gets or sets a value that defines how comments are handled during deserialization.

public ReferenceHandler ReferenceHandler { get; set; }

Gets or sets an object that specifies how object references are handled when reading and writing JSON.

public bool RespectNullableAnnotations { get; set; }

public bool RespectRequiredConstructorParameters { get; set; }

Gets or sets the JsonTypeInfo contract resolver used by this instance.

Gets the list of chained JsonTypeInfo contract resolvers used by this instance.

Gets or sets an object that specifies how deserializing a type declared as an Object is handled during deserialization.

Gets or sets an object that specifies how JsonSerializer handles JSON properties that cannot be mapped to a specific .NET member when deserializing object types.

public bool WriteIndented { get; set; }

Gets or sets a value that indicates whether JSON should use pretty printing. By default, JSON is serialized without any extra white space.

Initializes a new instance of the JsonSerializerOptions class.

Copies the options from a JsonSerializerOptions instance to a new instance.

Constructs a new JsonSerializerOptions instance with a predefined set of options determined by the specified JsonSerializerDefaults.

public void AddContext<TContext>() where TContext : JsonSerializerContext

Appends a new JsonSerializerContext to the metadata resolution of the current JsonSerializerOptions instance.

public JsonConverter GetConverter(Type typeToConvert)

Returns the converter for the specified type.

Gets the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.

public void MakeReadOnly()

Marks the current instance as read-only to prevent any further user modification.

public void MakeReadOnly(bool populateMissingResolver)

Marks the current instance as read-only preventing any further user modification.

public bool TryGetTypeInfo(Type type, out JsonTypeInfo typeInfo)

Tries to get the JsonTypeInfo contract metadata resolved by the current JsonSerializerOptions instance.