JsonWriterOptions 結構

定義

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

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

備註

根據預設,JSON 會寫入,而不需要任何縮排或額外的空格符。 此外,如果用戶嘗試寫入結構無效的 JSON,Utf8JsonWriter 會擲回例外狀況。

如需詳細資訊,請參閱 如何使用 System.Text.Json 撰寫自定義串行化程式和還原串行化程式

屬性

Encoder

取得或設定逸出字串時要使用的編碼器,或 null 使用預設編碼器。

IndentCharacter

定義啟用 Indented 時,Utf8JsonWriter 所使用的縮排字元。 預設為空格字元。

Indented

取得或設定值,這個值表示 Utf8JsonWriter 是否應該格式化 JSON 輸出,包括縮排巢狀 JSON 令牌、新增新行,以及在屬性名稱和值之間新增空格符。

IndentSize

定義啟用 Indented 時,Utf8JsonWriter 所使用的縮排大小。 預設值為 2。

MaxDepth

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

NewLine

取得或設定 Indentedtrue時要使用的新行字串。

預設值為 NewLine的值。

SkipValidation

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

適用於