<PackageReference Include="System.Text.Json" Version="9.0.3" />

JsonElement

public struct JsonElement
Represents a specific JSON value within a JsonDocument.

Represents an enumerator for the contents of a JSON array.

Represents an enumerator for the properties of a JSON object.

public JsonElement this[int index] { get; }

Gets the value at the specified index if the current value is an Array.

public JsonValueKind ValueKind { get; }

Gets the type of the current JSON value.

public static bool DeepEquals(JsonElement element1, JsonElement element2)

public static JsonElement ParseValue(ref Utf8JsonReader reader)

Parses one JSON value (including objects or arrays) from the provided reader.

public static bool TryParseValue(ref Utf8JsonReader reader, out Nullable element)

Attempts to parse one JSON value (including objects or arrays) from the provided reader.

public JsonElement Clone()

Gets a JsonElement that can be safely stored beyond the lifetime of the original JsonDocument.

Gets an enumerator to enumerate the values in the JSON array represented by this JsonElement.

Gets an enumerator to enumerate the properties in the JSON object represented by this JsonElement.

public int GetArrayLength()

Gets the number of values contained within the current array value.

public bool GetBoolean()

Gets the value of the element as a Boolean.

public byte GetByte()

Gets the current JSON number as a Byte.

public byte[] GetBytesFromBase64()

Gets the value of the element as a byte array.

Gets the value of the element as a DateTime.

Gets the value of the element as a DateTimeOffset.

public decimal GetDecimal()

Gets the current JSON number as a Decimal.

public double GetDouble()

Gets the current JSON number as a Double.

public Guid GetGuid()

Gets the value of the element as a Guid.

public short GetInt16()

Gets the current JSON number as an Int16.

public int GetInt32()

Gets the current JSON number as an Int32.

public long GetInt64()

Gets the current JSON number as an Int64.

public JsonElement GetProperty(string propertyName)

Gets a JsonElement representing the value of a required property identified by propertyName.

public JsonElement GetProperty(ReadOnlySpan<char> propertyName)

Gets a JsonElement representing the value of a required property identified by propertyName.

public JsonElement GetProperty(ReadOnlySpan<byte> utf8PropertyName)

Gets a JsonElement representing the value of a required property identified by utf8PropertyName.

public int GetPropertyCount()

public string GetRawText()

Gets a string that represents the original input data backing this value.

public sbyte GetSByte()

Gets the current JSON number as an SByte.

public float GetSingle()

Gets the current JSON number as a Single.

public string GetString()

Gets the value of the element as a String.

public ushort GetUInt16()

Gets the current JSON number as a UInt16.

public uint GetUInt32()

Gets the current JSON number as a UInt32.

public ulong GetUInt64()

Gets the current JSON number as a UInt64.

public bool TryGetByte(out byte value)

Attempts to represent the current JSON number as a Byte.

public bool TryGetBytesFromBase64(out byte value)

Attempts to represent the current JSON string as a byte array, assuming that it is Base64 encoded.

public bool TryGetDateTime(out DateTime value)

Attempts to represent the current JSON string as a DateTime.

public bool TryGetDateTimeOffset(out DateTimeOffset value)

Attempts to represent the current JSON string as a DateTimeOffset.

public bool TryGetDecimal(out decimal value)

Attempts to represent the current JSON number as a Decimal.

public bool TryGetDouble(out double value)

Attempts to represent the current JSON number as a Double.

public bool TryGetGuid(out Guid value)

Attempts to represent the current JSON string as a Guid.

public bool TryGetInt16(out short value)

Attempts to represent the current JSON number as an Int16.

public bool TryGetInt32(out int value)

Attempts to represent the current JSON number as an Int32.

public bool TryGetInt64(out long value)

Attempts to represent the current JSON number as a Int64.

public bool TryGetProperty(string propertyName, out JsonElement value)

Looks for a property named propertyName in the current object, returning a value that indicates whether or not such a property exists. When the property exists, its value is assigned to the value argument.

public bool TryGetProperty(ReadOnlySpan<char> propertyName, out JsonElement value)

Looks for a property named propertyName in the current object, returning a value that indicates whether or not such a property exists. When the property exists, the method assigns its value to the value argument.

public bool TryGetProperty(ReadOnlySpan<byte> utf8PropertyName, out JsonElement value)

Looks for a property named utf8PropertyName in the current object, returning a value that indicates whether or not such a property exists. When the property exists, the method assigns its value to the value argument.

public bool TryGetSByte(out sbyte value)

Attempts to represent the current JSON number as an SByte.

public bool TryGetSingle(out float value)

Attempts to represent the current JSON number as a Single.

public bool TryGetUInt16(out ushort value)

Attempts to represent the current JSON number as a UInt16.

public bool TryGetUInt32(out uint value)

Attempts to represent the current JSON number as a UInt32.

public bool TryGetUInt64(out ulong value)

Attempts to represent the current JSON number as a UInt64.

public bool ValueEquals(string text)

Compares a specified string to the string value of this element.

public bool ValueEquals(ReadOnlySpan<byte> utf8Text)

Compares the text represented by a UTF8-encoded byte span to the string value of this element.

public bool ValueEquals(ReadOnlySpan<char> text)

Compares a specified read-only character span to the string value of this element.

public void WriteTo(Utf8JsonWriter writer)

Writes the element to the specified writer as a JSON value.