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 則可使用預設編碼器。

Indented

取得或設定值,這個值指出 Utf8JsonWriter 是否應將 JSON 輸出格式化,其中包含縮排巢狀 JSON 權杖、新增新行,以及在屬性名稱與值之間新增空白字元。

MaxDepth

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

SkipValidation

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

適用於