JsonElement 結構

定義

表示 JsonDocument內的特定 JSON 值。

public value class JsonElement
public readonly struct JsonElement
type JsonElement = struct
Public Structure JsonElement
繼承
JsonElement

備註

欲了解更多資訊,請參閱 使用 JsonDocument 以存取資料

屬性

名稱 Description
Item[Int32]

若當前值為 Array,則在指定索引處取得該值。

ValueKind

取得目前 JSON 值的類型。

方法

名稱 Description
Clone()

會獲得一個 JsonElement,可以安全地儲存在原始 JsonDocumentJsonElement 的壽命之後。

DeepEquals(JsonElement, JsonElement)

比較兩個 JsonElement 相等值的值,包括所有後代元素的值。

EnumerateArray()

取得一個枚舉子來枚舉由 JsonElement 代表的 JSON 陣列中的值。

EnumerateObject()

取得一個枚舉器來枚舉這個 JsonElement 所代表的 JSON 物件中的屬性。

GetArrayLength()

取得目前陣列值中包含的數值。

GetBoolean()

取得元素的值為 Boolean

GetByte()

會取得目前的 JSON 編號為 Byte

GetBytesFromBase64()

以位元組陣列的形式取得元素的值。

GetDateTime()

取得元素的值為 DateTime

GetDateTimeOffset()

取得元素的值為 DateTimeOffset

GetDecimal()

會取得目前的 JSON 編號為 Decimal

GetDouble()

會取得目前的 JSON 編號為 Double

GetGuid()

取得元素的值為 Guid

GetInt16()

會以 . 取得目前的 JSON 編號。Int16

GetInt32()

會以 . 取得目前的 JSON 編號。Int32

GetInt64()

會以 . 取得目前的 JSON 編號。Int64

GetProperty(ReadOnlySpan<Byte>)

得到 JsonElement 一個代表由 utf8PropertyName所識別的必要屬性價值的 。

GetProperty(ReadOnlySpan<Char>)

得到 JsonElement 一個代表由 propertyName所識別的必要屬性價值的 。

GetProperty(String)

得到 JsonElement 一個代表由 propertyName所識別的必要屬性價值的 。

GetPropertyCount()

取得目前物件值中包含的屬性數量。

GetRawText()

會取得一個字串,代表這個值背後的原始輸入資料。

GetSByte()

會以 . 取得目前的 JSON 編號。SByte

GetSingle()

會取得目前的 JSON 編號為 Single

GetString()

取得元素的值為 String

GetUInt16()

會取得目前的 JSON 編號為 UInt16

GetUInt32()

會取得目前的 JSON 編號為 UInt32

GetUInt64()

會取得目前的 JSON 編號為 UInt64

Parse(ReadOnlySpan<Byte>, JsonDocumentOptions)

解析表示單一 JSON 值的 UTF8 編碼文字。JsonElement

Parse(ReadOnlySpan<Char>, JsonDocumentOptions)

將代表單一 JSON 值的文字解析成 JsonElement

Parse(String, JsonDocumentOptions)

將代表單一 JSON 值的文字解析成 JsonElement

ParseValue(Utf8JsonReader)

解析從所提供閱讀器中解析一個 JSON 值(包括物件或陣列)。

ToString()

會得到與該值類型相符的當前值字串表示。

TryGetByte(Byte)

嘗試將目前的 JSON 數字表示為 Byte.

TryGetBytesFromBase64(Byte[])

嘗試將目前的 JSON 字串表示為位元組陣列,假設它是 Base64 編碼的。

TryGetDateTime(DateTime)

嘗試將目前的 JSON 字串表示為 DateTime.

TryGetDateTimeOffset(DateTimeOffset)

嘗試將目前的 JSON 字串表示為 DateTimeOffset.

TryGetDecimal(Decimal)

嘗試將目前的 JSON 數字表示為 Decimal.

TryGetDouble(Double)

嘗試將目前的 JSON 數字表示為 Double.

TryGetGuid(Guid)

嘗試將目前的 JSON 字串表示為 Guid.

TryGetInt16(Int16)

嘗試將目前的 JSON 數字表示為 Int16.

TryGetInt32(Int32)

嘗試將目前的 JSON 數字表示為 Int32.

TryGetInt64(Int64)

嘗試將目前的 JSON 數字表示為 Int64.

TryGetProperty(ReadOnlySpan<Byte>, JsonElement)

尋找目前物件中命名 utf8PropertyName 的屬性,回傳一個值以指示該屬性是否存在。 當該屬性存在時,方法會將其值指派給 value 參數。

TryGetProperty(ReadOnlySpan<Char>, JsonElement)

尋找目前物件中命名 propertyName 的屬性,回傳一個值以指示該屬性是否存在。 當該屬性存在時,方法會將其值指派給 value 參數。

TryGetProperty(String, JsonElement)

尋找目前物件中命名 propertyName 的屬性,回傳一個值以指示該屬性是否存在。 當該性質存在時,其值會被 value 賦予參數。

TryGetSByte(SByte)

嘗試將目前的 JSON 數字表示為 SByte.

TryGetSingle(Single)

嘗試將目前的 JSON 數字表示為 Single.

TryGetUInt16(UInt16)

嘗試將目前的 JSON 數字表示為 UInt16.

TryGetUInt32(UInt32)

嘗試將目前的 JSON 數字表示為 UInt32.

TryGetUInt64(UInt64)

嘗試將目前的 JSON 數字表示為 UInt64.

TryParseValue(Utf8JsonReader, Nullable<JsonElement>)

嘗試從所提供的讀取器解析一個 JSON 值(包括物件或陣列)。

ValueEquals(ReadOnlySpan<Byte>)

比較以 UTF8 編碼的位元組區間所代表的文字與此元素的字串值。

ValueEquals(ReadOnlySpan<Char>)

比較指定的唯讀字元張距與該元素的字串值。

ValueEquals(String)

比較指定字串與該元素的字串值。

WriteTo(Utf8JsonWriter)

將該元素以 JSON 值寫入指定的寫入者。

擴充方法

名稱 Description
Deserialize(JsonElement, JsonTypeInfo)

JsonElement 代表單一 JSON 值的 轉換為由 jsonTypeInfo.

Deserialize(JsonElement, Type, JsonSerializerContext)

JsonElement 代表單一 JSON 值的 returnType轉換為 。

Deserialize(JsonElement, Type, JsonSerializerOptions)

JsonElement 代表單一 JSON 值的 returnType轉換為 。

Deserialize<TValue>(JsonElement, JsonSerializerOptions)

JsonElement 代表單一 JSON 值的 TValue轉換為 。

Deserialize<TValue>(JsonElement, JsonTypeInfo<TValue>)

JsonElement 代表單一 JSON 值的 TValue轉換為 。

適用於