JsonDocumentOptions
Provides the ability for the user to define custom behavior when parsing JSON to create a JsonDocument.
using System.Runtime.CompilerServices;
namespace System.Text.Json
{
public struct JsonDocumentOptions
{
internal const int DefaultMaxDepth = 64;
private int _maxDepth;
private JsonCommentHandling _commentHandling;
public JsonCommentHandling CommentHandling {
[System.Runtime.CompilerServices.IsReadOnly]
get {
return _commentHandling;
}
set {
if ((int)value > 1)
throw new ArgumentOutOfRangeException("value", System.SR.JsonDocumentDoesNotSupportComments);
_commentHandling = value;
}
}
public int MaxDepth {
[System.Runtime.CompilerServices.IsReadOnly]
get {
return _maxDepth;
}
set {
if (value < 0)
ThrowHelper.ThrowArgumentOutOfRangeException_MaxDepthMustBePositive("value");
_maxDepth = value;
}
}
public bool AllowTrailingCommas {
[System.Runtime.CompilerServices.IsReadOnly]
get;
set;
}
internal JsonReaderOptions GetReaderOptions()
{
JsonReaderOptions result = default(JsonReaderOptions);
result.AllowTrailingCommas = AllowTrailingCommas;
result.CommentHandling = CommentHandling;
result.MaxDepth = MaxDepth;
return result;
}
}
}