JsonSerializerOptions.WriteIndented 屬性

定義

取得或設定值,這個值表示 JSON 是否應該使用美式列印。 根據預設,JSON 會序列化,而不會有任何額外的空白字元。

public:
 property bool WriteIndented { bool get(); void set(bool value); };
public bool WriteIndented { get; set; }
member this.WriteIndented : bool with get, set
Public Property WriteIndented As Boolean

屬性值

true 如果 JSON 在序列化上很美觀,則為 ;否則為 false 。 預設值為 false

例外狀況

此屬性是在序列化或還原序列化發生後設定的。

備註

美化列印包括:

  • 縮排巢狀 JSON 權杖。
  • 新增行
  • 在屬性名稱和值之間新增空白字元。

如需詳細資訊,請參閱 如何序列化和還原序列化 JSON

適用於