JsonSerializerOptions.AllowTrailingCommas 属性
定义
获取或设置一个值,该值指示要反序列化的 JSON 有效负载中是否允许(和忽略)对象或数组中 JSON 值的列表末尾多余的逗号。Get or sets a value that indicates whether an extra comma at the end of a list of JSON values in an object or array is allowed (and ignored) within the JSON payload being deserialized.
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 否则为。true if an extra comma at the end of a list of JSON values in an object or array is allowed (and ignored); false otherwise.
例外
此属性在序列化或反序列化发生后设置。This property was set after serialization or deserialization has occurred.
注解
默认情况下, AllowTrailingCommas 设置为 false ,并在 JsonException 反序列化过程中如果遇到尾部逗号,则会引发。By default, AllowTrailingCommas is set to false, and a JsonException is thrown during deserialization if a trailing comma is encountered.
有关详细信息,请参阅 如何允许 System.Text.Js上的某些类型的无效 JSON。For more information, see How to allow some kinds of invalid JSON with System.Text.Json.