語言

JsonWriterOptions 結構

定義

允許使用者在使用 Utf8JsonWriter撰寫 JSON 時定義自訂行為。

public value class JsonWriterOptions
public struct JsonWriterOptions
type JsonWriterOptions = struct
Public Structure JsonWriterOptions
繼承
JsonWriterOptions

備註

預設情況下,JSON 是沒有縮排或額外留白的。 此外, Utf8JsonWriter 如果使用者嘗試寫出結構無效的 JSON,會拋出例外。

欲了解更多資訊,請參閱 如何使用 System.Text.JSON 撰寫自訂序列化器與解序列器。

屬性

名稱 Description
Encoder

取得或設定編碼器,使其在逃離字串時使用,或 null 使用預設編碼器。

IndentCharacter

定義啟用時Indented所使用的Utf8JsonWriter縮排字元。 預設是太空角色。

Indented

取得或設定一個值,指示是否 Utf8JsonWriter 應該格式化 JSON 輸出,包括縮排巢狀 JSON 標記、新增行數,以及在屬性名稱和值之間增加空白。

IndentSize

定義啟用時Indented所使用的Utf8JsonWriter縮排大小。 預設是二。

MaxDepth

在寫入 JSON 時,會取得或設定最大允許的深度,預設值(即 0)表示最大深度為 1000。

NewLine

當 是 true時,會取得或設定新的行串以使用Indented。

預設為 NewLine 的值。

SkipValidation

取得或設定一個值,指示是否 Utf8JsonWriter 應該跳過結構驗證,允許使用者寫入無效的 JSON。

適用於