<PackageReference Include="System.Text.Json" Version="9.0.5" />

JsonWriterOptions

public struct JsonWriterOptions
Allows the user to define custom behavior when writing JSON using the Utf8JsonWriter.
public JavaScriptEncoder Encoder { get; set; }

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

public char IndentCharacter { get; set; }

Defines the indentation character used by Utf8JsonWriter when Indented is enabled. Defaults to the space character.

public bool Indented { get; set; }

Gets or sets a value that indicates whether the Utf8JsonWriter should format the JSON output, which includes indenting nested JSON tokens, adding new lines, and adding white space between property names and values.

public int IndentSize { get; set; }

Defines the indentation size used by Utf8JsonWriter when Indented is enabled. Defaults to two.

public int MaxDepth { get; set; }

Gets or sets the maximum depth allowed when writing JSON, with the default (that is, 0) indicating a max depth of 1000.

public string NewLine { get; set; }

Gets or sets the new line string to use when Indented is true.

The default is the value of NewLine.

public bool SkipValidation { get; set; }

Gets or sets a value that indicates whether the Utf8JsonWriter should skip structural validation and allow the user to write invalid JSON.