Property AllowComments
AllowComments
Gets or sets a value indicating whether comments are allowed in
the JSON input.
Declaration
public bool AllowComments { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
true to allow comments, false to disallow comments.
The default is false .
|
Remarks
If allowed, comments follow the C# syntax, using // for single-line comments and /* */ for single-line and multi-line comments. If comments are not allowed and comments are encountered in JSON input, FromJsonString(String, JsonInputOptions) will throw JsonParseException.
This option does not apply to DeserializeFromJson(ref Utf8JsonReader, JsonInputOptions) (instead use JsonReaderOptions when creating Utf8JsonReader).
Examples
JSON with comments.{
"key1": "string value", // single-line comment
"key2": 10, /* another single-line comment */
/*
Multi-line
comment.
*/
"key3": null
}