# System.Text.Json ``` diff +namespace System.Text.Json { + public enum JsonCommentHandling : byte { + Allow = (byte)2, + Disallow = (byte)0, + Skip = (byte)1, + } + public sealed class JsonDocument : IDisposable { + public JsonElement RootElement { get; } + public void Dispose(); + public static JsonDocument Parse(ReadOnlySequence utf8Json, JsonDocumentOptions options = default(JsonDocumentOptions)); + public static JsonDocument Parse(Stream utf8Json, JsonDocumentOptions options = default(JsonDocumentOptions)); + public static JsonDocument Parse(ReadOnlyMemory utf8Json, JsonDocumentOptions options = default(JsonDocumentOptions)); + public static JsonDocument Parse(ReadOnlyMemory json, JsonDocumentOptions options = default(JsonDocumentOptions)); + public static JsonDocument Parse(string json, JsonDocumentOptions options = default(JsonDocumentOptions)); + public static Task ParseAsync(Stream utf8Json, JsonDocumentOptions options = default(JsonDocumentOptions), CancellationToken cancellationToken = default(CancellationToken)); + public static JsonDocument ParseValue(ref Utf8JsonReader reader); + public static bool TryParseValue(ref Utf8JsonReader reader, out JsonDocument document); + public void WriteTo(Utf8JsonWriter writer); + } + public struct JsonDocumentOptions { + public bool AllowTrailingCommas { get; set; } + public JsonCommentHandling CommentHandling { get; set; } + public int MaxDepth { get; set; } + } + public readonly struct JsonElement { + public JsonElement this[int index] { get; } + public JsonValueKind ValueKind { get; } + public JsonElement Clone(); + public JsonElement.ArrayEnumerator EnumerateArray(); + public JsonElement.ObjectEnumerator EnumerateObject(); + public int GetArrayLength(); + public bool GetBoolean(); + public byte GetByte(); + public byte[] GetBytesFromBase64(); + public DateTime GetDateTime(); + public DateTimeOffset GetDateTimeOffset(); + public decimal GetDecimal(); + public double GetDouble(); + public Guid GetGuid(); + public short GetInt16(); + public int GetInt32(); + public long GetInt64(); + public JsonElement GetProperty(ReadOnlySpan utf8PropertyName); + public JsonElement GetProperty(ReadOnlySpan propertyName); + public JsonElement GetProperty(string propertyName); + public string GetRawText(); + public sbyte GetSByte(); + public float GetSingle(); + public string GetString(); + public ushort GetUInt16(); + public uint GetUInt32(); + public ulong GetUInt64(); + public override string ToString(); + public bool TryGetByte(out byte value); + public bool TryGetBytesFromBase64(out byte[] value); + public bool TryGetDateTime(out DateTime value); + public bool TryGetDateTimeOffset(out DateTimeOffset value); + public bool TryGetDecimal(out decimal value); + public bool TryGetDouble(out double value); + public bool TryGetGuid(out Guid value); + public bool TryGetInt16(out short value); + public bool TryGetInt32(out int value); + public bool TryGetInt64(out long value); + public bool TryGetProperty(ReadOnlySpan utf8PropertyName, out JsonElement value); + public bool TryGetProperty(ReadOnlySpan propertyName, out JsonElement value); + public bool TryGetProperty(string propertyName, out JsonElement value); + public bool TryGetSByte(out sbyte value); + public bool TryGetSingle(out float value); + public bool TryGetUInt16(out ushort value); + public bool TryGetUInt32(out uint value); + public bool TryGetUInt64(out ulong value); + public bool ValueEquals(ReadOnlySpan utf8Text); + public bool ValueEquals(ReadOnlySpan text); + public bool ValueEquals(string text); + public void WriteTo(Utf8JsonWriter writer); + public struct ArrayEnumerator : IDisposable, IEnumerable, IEnumerable, IEnumerator, IEnumerator { + public JsonElement Current { get; } + object System.Collections.IEnumerator.Current { get; } + public void Dispose(); + public JsonElement.ArrayEnumerator GetEnumerator(); + public bool MoveNext(); + public void Reset(); + IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator(); + IEnumerator System.Collections.IEnumerable.GetEnumerator(); + } + public struct ObjectEnumerator : IDisposable, IEnumerable, IEnumerable, IEnumerator, IEnumerator { + public JsonProperty Current { get; } + object System.Collections.IEnumerator.Current { get; } + public void Dispose(); + public JsonElement.ObjectEnumerator GetEnumerator(); + public bool MoveNext(); + public void Reset(); + IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator(); + IEnumerator System.Collections.IEnumerable.GetEnumerator(); + } + } + public readonly struct JsonEncodedText : IEquatable { + public ReadOnlySpan EncodedUtf8Bytes { get; } + public static JsonEncodedText Encode(ReadOnlySpan utf8Value, JavaScriptEncoder encoder = null); + public static JsonEncodedText Encode(ReadOnlySpan value, JavaScriptEncoder encoder = null); + public static JsonEncodedText Encode(string value, JavaScriptEncoder encoder = null); + public override bool Equals(object obj); + public bool Equals(JsonEncodedText other); + public override int GetHashCode(); + public override string ToString(); + } + public class JsonException : Exception { + public JsonException(); + protected JsonException(SerializationInfo info, StreamingContext context); + public JsonException(string message); + public JsonException(string message, Exception innerException); + public JsonException(string message, string path, long? lineNumber, long? bytePositionInLine); + public JsonException(string message, string path, long? lineNumber, long? bytePositionInLine, Exception innerException); + public long? BytePositionInLine { get; } + public long? LineNumber { get; } + public override string Message { get; } + public string Path { get; } + public override void GetObjectData(SerializationInfo info, StreamingContext context); + } + public abstract class JsonNamingPolicy { + protected JsonNamingPolicy(); + public static JsonNamingPolicy CamelCase { get; } + public abstract string ConvertName(string name); + } + public readonly struct JsonProperty { + public string Name { get; } + public JsonElement Value { get; } + public bool NameEquals(ReadOnlySpan utf8Text); + public bool NameEquals(ReadOnlySpan text); + public bool NameEquals(string text); + public override string ToString(); + public void WriteTo(Utf8JsonWriter writer); + } + public struct JsonReaderOptions { + public bool AllowTrailingCommas { get; set; } + public JsonCommentHandling CommentHandling { get; set; } + public int MaxDepth { get; set; } + } + public struct JsonReaderState { + public JsonReaderState(JsonReaderOptions options = default(JsonReaderOptions)); + public JsonReaderOptions Options { get; } + } + public static class JsonSerializer { + public static object Deserialize(ReadOnlySpan utf8Json, Type returnType, JsonSerializerOptions options = null); + public static object Deserialize(string json, Type returnType, JsonSerializerOptions options = null); + public static object Deserialize(ref Utf8JsonReader reader, Type returnType, JsonSerializerOptions options = null); + public static TValue Deserialize(ReadOnlySpan utf8Json, JsonSerializerOptions options = null); + public static TValue Deserialize(string json, JsonSerializerOptions options = null); + public static TValue Deserialize(ref Utf8JsonReader reader, JsonSerializerOptions options = null); + public static ValueTask DeserializeAsync(Stream utf8Json, Type returnType, JsonSerializerOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); + public static ValueTask DeserializeAsync(Stream utf8Json, JsonSerializerOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); + public static string Serialize(object value, Type inputType, JsonSerializerOptions options = null); + public static void Serialize(Utf8JsonWriter writer, object value, Type inputType, JsonSerializerOptions options = null); + public static void Serialize(Utf8JsonWriter writer, TValue value, JsonSerializerOptions options = null); + public static string Serialize(TValue value, JsonSerializerOptions options = null); + public static Task SerializeAsync(Stream utf8Json, object value, Type inputType, JsonSerializerOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); + public static Task SerializeAsync(Stream utf8Json, TValue value, JsonSerializerOptions options = null, CancellationToken cancellationToken = default(CancellationToken)); + public static byte[] SerializeToUtf8Bytes(object value, Type inputType, JsonSerializerOptions options = null); + public static byte[] SerializeToUtf8Bytes(TValue value, JsonSerializerOptions options = null); + } + public enum JsonSerializerDefaults { + General = 0, + Web = 1, + } + public sealed class JsonSerializerOptions { + public JsonSerializerOptions(); + public JsonSerializerOptions(JsonSerializerDefaults defaults); + public JsonSerializerOptions(JsonSerializerOptions options); + public bool AllowTrailingCommas { get; set; } + public IList Converters { get; } + public int DefaultBufferSize { get; set; } + public JsonIgnoreCondition DefaultIgnoreCondition { get; set; } + public JsonNamingPolicy DictionaryKeyPolicy { get; set; } + public JavaScriptEncoder Encoder { get; set; } + public bool IgnoreNullValues { get; set; } + public bool IgnoreReadOnlyFields { get; set; } + public bool IgnoreReadOnlyProperties { get; set; } + public bool IncludeFields { get; set; } + public int MaxDepth { get; set; } + public JsonNumberHandling NumberHandling { get; set; } + public bool PropertyNameCaseInsensitive { get; set; } + public JsonNamingPolicy PropertyNamingPolicy { get; set; } + public JsonCommentHandling ReadCommentHandling { get; set; } + public ReferenceHandler ReferenceHandler { get; set; } + public bool WriteIndented { get; set; } + public JsonConverter GetConverter(Type typeToConvert); + } + public enum JsonTokenType : byte { + Comment = (byte)6, + EndArray = (byte)4, + EndObject = (byte)2, + False = (byte)10, + None = (byte)0, + Null = (byte)11, + Number = (byte)8, + PropertyName = (byte)5, + StartArray = (byte)3, + StartObject = (byte)1, + String = (byte)7, + True = (byte)9, + } + public enum JsonValueKind : byte { + Array = (byte)2, + False = (byte)6, + Null = (byte)7, + Number = (byte)4, + Object = (byte)1, + String = (byte)3, + True = (byte)5, + Undefined = (byte)0, + } + public struct JsonWriterOptions { + public JavaScriptEncoder Encoder { get; set; } + public bool Indented { get; set; } + public bool SkipValidation { get; set; } + } + public ref struct Utf8JsonReader { + public Utf8JsonReader(ReadOnlySequence jsonData, bool isFinalBlock, JsonReaderState state); + public Utf8JsonReader(ReadOnlySequence jsonData, JsonReaderOptions options = default(JsonReaderOptions)); + public Utf8JsonReader(ReadOnlySpan jsonData, bool isFinalBlock, JsonReaderState state); + public Utf8JsonReader(ReadOnlySpan jsonData, JsonReaderOptions options = default(JsonReaderOptions)); + public long BytesConsumed { get; } + public int CurrentDepth { get; } + public JsonReaderState CurrentState { get; } + public bool HasValueSequence { get; } + public bool IsFinalBlock { get; } + public SequencePosition Position { get; } + public long TokenStartIndex { get; } + public JsonTokenType TokenType { get; } + public ReadOnlySequence ValueSequence { get; } + public ReadOnlySpan ValueSpan { get; } + public bool GetBoolean(); + public byte GetByte(); + public byte[] GetBytesFromBase64(); + public string GetComment(); + public DateTime GetDateTime(); + public DateTimeOffset GetDateTimeOffset(); + public decimal GetDecimal(); + public double GetDouble(); + public Guid GetGuid(); + public short GetInt16(); + public int GetInt32(); + public long GetInt64(); + public sbyte GetSByte(); + public float GetSingle(); + public string GetString(); + public ushort GetUInt16(); + public uint GetUInt32(); + public ulong GetUInt64(); + public bool Read(); + public void Skip(); + public bool TryGetByte(out byte value); + public bool TryGetBytesFromBase64(out byte[] value); + public bool TryGetDateTime(out DateTime value); + public bool TryGetDateTimeOffset(out DateTimeOffset value); + public bool TryGetDecimal(out decimal value); + public bool TryGetDouble(out double value); + public bool TryGetGuid(out Guid value); + public bool TryGetInt16(out short value); + public bool TryGetInt32(out int value); + public bool TryGetInt64(out long value); + public bool TryGetSByte(out sbyte value); + public bool TryGetSingle(out float value); + public bool TryGetUInt16(out ushort value); + public bool TryGetUInt32(out uint value); + public bool TryGetUInt64(out ulong value); + public bool TrySkip(); + public bool ValueTextEquals(ReadOnlySpan utf8Text); + public bool ValueTextEquals(ReadOnlySpan text); + public bool ValueTextEquals(string text); + } + public sealed class Utf8JsonWriter : IAsyncDisposable, IDisposable { + public Utf8JsonWriter(IBufferWriter bufferWriter, JsonWriterOptions options = default(JsonWriterOptions)); + public Utf8JsonWriter(Stream utf8Json, JsonWriterOptions options = default(JsonWriterOptions)); + public long BytesCommitted { get; } + public int BytesPending { get; } + public int CurrentDepth { get; } + public JsonWriterOptions Options { get; } + public void Dispose(); + public ValueTask DisposeAsync(); + public void Flush(); + public Task FlushAsync(CancellationToken cancellationToken = default(CancellationToken)); + public void Reset(); + public void Reset(IBufferWriter bufferWriter); + public void Reset(Stream utf8Json); + public void WriteBase64String(ReadOnlySpan utf8PropertyName, ReadOnlySpan bytes); + public void WriteBase64String(ReadOnlySpan propertyName, ReadOnlySpan bytes); + public void WriteBase64String(string propertyName, ReadOnlySpan bytes); + public void WriteBase64String(JsonEncodedText propertyName, ReadOnlySpan bytes); + public void WriteBase64StringValue(ReadOnlySpan bytes); + public void WriteBoolean(ReadOnlySpan utf8PropertyName, bool value); + public void WriteBoolean(ReadOnlySpan propertyName, bool value); + public void WriteBoolean(string propertyName, bool value); + public void WriteBoolean(JsonEncodedText propertyName, bool value); + public void WriteBooleanValue(bool value); + public void WriteCommentValue(ReadOnlySpan utf8Value); + public void WriteCommentValue(ReadOnlySpan value); + public void WriteCommentValue(string value); + public void WriteEndArray(); + public void WriteEndObject(); + public void WriteNull(ReadOnlySpan utf8PropertyName); + public void WriteNull(ReadOnlySpan propertyName); + public void WriteNull(string propertyName); + public void WriteNull(JsonEncodedText propertyName); + public void WriteNullValue(); + public void WriteNumber(ReadOnlySpan utf8PropertyName, decimal value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, double value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, int value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, long value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, float value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, uint value); + public void WriteNumber(ReadOnlySpan utf8PropertyName, ulong value); + public void WriteNumber(ReadOnlySpan propertyName, decimal value); + public void WriteNumber(ReadOnlySpan propertyName, double value); + public void WriteNumber(ReadOnlySpan propertyName, int value); + public void WriteNumber(ReadOnlySpan propertyName, long value); + public void WriteNumber(ReadOnlySpan propertyName, float value); + public void WriteNumber(ReadOnlySpan propertyName, uint value); + public void WriteNumber(ReadOnlySpan propertyName, ulong value); + public void WriteNumber(string propertyName, decimal value); + public void WriteNumber(string propertyName, double value); + public void WriteNumber(string propertyName, int value); + public void WriteNumber(string propertyName, long value); + public void WriteNumber(string propertyName, float value); + public void WriteNumber(string propertyName, uint value); + public void WriteNumber(string propertyName, ulong value); + public void WriteNumber(JsonEncodedText propertyName, decimal value); + public void WriteNumber(JsonEncodedText propertyName, double value); + public void WriteNumber(JsonEncodedText propertyName, int value); + public void WriteNumber(JsonEncodedText propertyName, long value); + public void WriteNumber(JsonEncodedText propertyName, float value); + public void WriteNumber(JsonEncodedText propertyName, uint value); + public void WriteNumber(JsonEncodedText propertyName, ulong value); + public void WriteNumberValue(decimal value); + public void WriteNumberValue(double value); + public void WriteNumberValue(int value); + public void WriteNumberValue(long value); + public void WriteNumberValue(float value); + public void WriteNumberValue(uint value); + public void WriteNumberValue(ulong value); + public void WritePropertyName(ReadOnlySpan utf8PropertyName); + public void WritePropertyName(ReadOnlySpan propertyName); + public void WritePropertyName(string propertyName); + public void WritePropertyName(JsonEncodedText propertyName); + public void WriteStartArray(); + public void WriteStartArray(ReadOnlySpan utf8PropertyName); + public void WriteStartArray(ReadOnlySpan propertyName); + public void WriteStartArray(string propertyName); + public void WriteStartArray(JsonEncodedText propertyName); + public void WriteStartObject(); + public void WriteStartObject(ReadOnlySpan utf8PropertyName); + public void WriteStartObject(ReadOnlySpan propertyName); + public void WriteStartObject(string propertyName); + public void WriteStartObject(JsonEncodedText propertyName); + public void WriteString(ReadOnlySpan utf8PropertyName, DateTime value); + public void WriteString(ReadOnlySpan utf8PropertyName, DateTimeOffset value); + public void WriteString(ReadOnlySpan utf8PropertyName, Guid value); + public void WriteString(ReadOnlySpan utf8PropertyName, ReadOnlySpan utf8Value); + public void WriteString(ReadOnlySpan utf8PropertyName, ReadOnlySpan value); + public void WriteString(ReadOnlySpan utf8PropertyName, string value); + public void WriteString(ReadOnlySpan utf8PropertyName, JsonEncodedText value); + public void WriteString(ReadOnlySpan propertyName, DateTime value); + public void WriteString(ReadOnlySpan propertyName, DateTimeOffset value); + public void WriteString(ReadOnlySpan propertyName, Guid value); + public void WriteString(ReadOnlySpan propertyName, ReadOnlySpan utf8Value); + public void WriteString(ReadOnlySpan propertyName, ReadOnlySpan value); + public void WriteString(ReadOnlySpan propertyName, string value); + public void WriteString(ReadOnlySpan propertyName, JsonEncodedText value); + public void WriteString(string propertyName, DateTime value); + public void WriteString(string propertyName, DateTimeOffset value); + public void WriteString(string propertyName, Guid value); + public void WriteString(string propertyName, ReadOnlySpan utf8Value); + public void WriteString(string propertyName, ReadOnlySpan value); + public void WriteString(string propertyName, string value); + public void WriteString(string propertyName, JsonEncodedText value); + public void WriteString(JsonEncodedText propertyName, DateTime value); + public void WriteString(JsonEncodedText propertyName, DateTimeOffset value); + public void WriteString(JsonEncodedText propertyName, Guid value); + public void WriteString(JsonEncodedText propertyName, ReadOnlySpan utf8Value); + public void WriteString(JsonEncodedText propertyName, ReadOnlySpan value); + public void WriteString(JsonEncodedText propertyName, string value); + public void WriteString(JsonEncodedText propertyName, JsonEncodedText value); + public void WriteStringValue(DateTime value); + public void WriteStringValue(DateTimeOffset value); + public void WriteStringValue(Guid value); + public void WriteStringValue(ReadOnlySpan utf8Value); + public void WriteStringValue(ReadOnlySpan value); + public void WriteStringValue(string value); + public void WriteStringValue(JsonEncodedText value); + } +} ```