JsonSerializerOptions.AllowTrailingCommas 屬性

定義

取得或設定值,指出在所要還原序列化的 JSON 承載內,是否允許 (並忽略) 物件或陣列中的 JSON 值清單結尾有額外逗號。

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

屬性值

true 如果允許物件或陣列中 JSON 值清單結尾的額外逗號, (並忽略) ; false 否則。

例外狀況

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

備註

根據預設, AllowTrailingCommas 設為 false ,如果 JsonException 遇到尾端逗號,則會在還原序列化期間擲回 。

如需詳細資訊,請參閱 如何使用 System.Text.Json 允許某種不正確 JSON

適用於