Note
Access to this page requires authorization. You can try signing in or .
Access to this page requires authorization. You can try .
JsonElement Struct
Definition
- Namespace:
- System.Text.Json
- Assembly:
- System.Text.Json.dll
- Package:
- System.Text.Json v11.0.0-preview.5.26302.115
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
Important
Some information relates to prerelease product that may be substantially modified before itβs released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Represents a specific JSON value within a JsonDocument.
public value class JsonElement
public readonly struct JsonElement
type JsonElement = struct
Public Structure JsonElement
- Inheritance
Remarks
For more information, see Use JsonDocument for access to data.
Properties
| Name | Description |
|---|---|
| Item[Int32] |
Gets the value at the specified index if the current value is an Array. |
| ValueKind |
Gets the type of the current JSON value. |
Methods
| Name | Description |
|---|---|
| Clone() |
Gets a JsonElement that can be safely stored beyond the lifetime of the original JsonDocument. |
| DeepEquals(JsonElement, JsonElement) |
Compares the values of two JsonElement values for equality, including the values of all descendant elements. |
| EnumerateArray() |
Gets an enumerator to enumerate the values in the JSON array represented by this JsonElement. |
| EnumerateObject() |
Gets an enumerator to enumerate the properties in the JSON object represented by this JsonElement. |
| GetArrayLength() |
Gets the number of values contained within the current array value. |
| GetBoolean() |
Gets the value of the element as a Boolean. |
| GetByte() |
Gets the current JSON number as a Byte. |
| GetBytesFromBase64() |
Gets the value of the element as a byte array. |
| GetDateTime() |
Gets the value of the element as a DateTime. |
| GetDateTimeOffset() |
Gets the value of the element as a DateTimeOffset. |
| GetDecimal() |
Gets the current JSON number as a Decimal. |
| GetDouble() |
Gets the current JSON number as a Double. |
| GetGuid() |
Gets the value of the element as a Guid. |
| GetInt16() |
Gets the current JSON number as an Int16. |
| GetInt32() |
Gets the current JSON number as an Int32. |
| GetInt64() |
Gets the current JSON number as an Int64. |
| GetProperty(ReadOnlySpan<Byte>) |
Gets a JsonElement representing the value of a required property identified by |
| GetProperty(ReadOnlySpan<Char>) |
Gets a JsonElement representing the value of a required property identified by |
| GetProperty(String) |
Gets a JsonElement representing the value of a required property identified by |
| GetPropertyCount() |
Gets the number of properties contained within the current object value. |
| GetRawText() |
Gets a string that represents the original input data backing this value. |
| GetSByte() |
Gets the current JSON number as an SByte. |
| GetSingle() |
Gets the current JSON number as a Single. |
| GetString() |
Gets the value of the element as a String. |
| GetUInt16() |
Gets the current JSON number as a UInt16. |
| GetUInt32() |
Gets the current JSON number as a UInt32. |
| GetUInt64() |
Gets the current JSON number as a UInt64. |
| Parse(ReadOnlySpan<Byte>, JsonDocumentOptions) |
Parses UTF8-encoded text representing a single JSON value into a JsonElement. |
| Parse(ReadOnlySpan<Char>, JsonDocumentOptions) |
Parses text representing a single JSON value into a JsonElement. |
| Parse(String, JsonDocumentOptions) |
Parses text representing a single JSON value into a JsonElement. |
| ParseValue(Utf8JsonReader) |
Parses one JSON value (including objects or arrays) from the provided reader. |
| ToString() |
Gets a string representation for the current value appropriate to the value type. |
| TryGetByte(Byte) |
Attempts to represent the current JSON number as a Byte. |
| TryGetBytesFromBase64(Byte[]) |
Attempts to represent the current JSON string as a byte array, assuming that it is Base64 encoded. |
| TryGetDateTime(DateTime) |
Attempts to represent the current JSON string as a DateTime. |
| TryGetDateTimeOffset(DateTimeOffset) |
Attempts to represent the current JSON string as a DateTimeOffset. |
| TryGetDecimal(Decimal) |
Attempts to represent the current JSON number as a Decimal. |
| TryGetDouble(Double) |
Attempts to represent the current JSON number as a Double. |
| TryGetGuid(Guid) |
Attempts to represent the current JSON string as a Guid. |
| TryGetInt16(Int16) |
Attempts to represent the current JSON number as an Int16. |
| TryGetInt32(Int32) |
Attempts to represent the current JSON number as an Int32. |
| TryGetInt64(Int64) |
Attempts to represent the current JSON number as a Int64. |
| TryGetProperty(ReadOnlySpan<Byte>, JsonElement) |
Looks for a property named |
| TryGetProperty(ReadOnlySpan<Char>, JsonElement) |
Looks for a property named |
| TryGetProperty(String, JsonElement) |
Looks for a property named |
| TryGetSByte(SByte) |
Attempts to represent the current JSON number as an SByte. |
| TryGetSingle(Single) |
Attempts to represent the current JSON number as a Single. |
| TryGetUInt16(UInt16) |
Attempts to represent the current JSON number as a UInt16. |
| TryGetUInt32(UInt32) |
Attempts to represent the current JSON number as a UInt32. |
| TryGetUInt64(UInt64) |
Attempts to represent the current JSON number as a UInt64. |
| TryParseValue(Utf8JsonReader, Nullable<JsonElement>) |
Attempts to parse one JSON value (including objects or arrays) from the provided reader. |
| ValueEquals(ReadOnlySpan<Byte>) |
Compares the text represented by a UTF8-encoded byte span to the string value of this element. |
| ValueEquals(ReadOnlySpan<Char>) |
Compares a specified read-only character span to the string value of this element. |
| ValueEquals(String) |
Compares a specified string to the string value of this element. |
| WriteTo(Utf8JsonWriter) |
Writes the element to the specified writer as a JSON value. |
Extension Methods
| Name | Description |
|---|---|
| Deserialize(JsonElement, JsonTypeInfo) |
Converts the JsonElement representing a single JSON value into an instance specified by the |
| Deserialize(JsonElement, Type, JsonSerializerContext) |
Converts the JsonElement representing a single JSON value into a |
| Deserialize(JsonElement, Type, JsonSerializerOptions) |
Converts the JsonElement representing a single JSON value into a |
| Deserialize<TValue>(JsonElement, JsonSerializerOptions) |
Converts the JsonElement representing a single JSON value into a |
| Deserialize<TValue>(JsonElement, JsonTypeInfo<TValue>) |
Converts the JsonElement representing a single JSON value into a |
Applies to
Feedback
Was this page helpful?
