JsonSerializerOptions.ReadCommentHandling Property

Definition

Gets or sets a value that defines how comments are handled during deserialization.

C#
public System.Text.Json.JsonCommentHandling ReadCommentHandling { get; set; }

Property Value

A value that indicates whether comments are allowed, disallowed, or skipped.

Exceptions

This property was set after serialization or deserialization has occurred.

The comment handling enum is set to a value that is not supported (or not within the JsonCommentHandling enum range).

Remarks

By default, a JsonException is thrown during deserialization if a comment is encountered.

For more information, see How to allow some kinds of invalid JSON with System.Text.Json.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)