JsonElement.GetProperty 方法

定义

重载

GetProperty(ReadOnlySpan<Byte>)

获取一个 JsonElement,它表示由 utf8PropertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by utf8PropertyName.

GetProperty(ReadOnlySpan<Char>)

获取一个 JsonElement,它表示由 propertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by propertyName.

GetProperty(String)

获取一个 JsonElement,它表示由 propertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by propertyName.

GetProperty(ReadOnlySpan<Byte>)

获取一个 JsonElement,它表示由 utf8PropertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by utf8PropertyName.

public:
 System::Text::Json::JsonElement GetProperty(ReadOnlySpan<System::Byte> utf8PropertyName);
public System.Text.Json.JsonElement GetProperty (ReadOnlySpan<byte> utf8PropertyName);
member this.GetProperty : ReadOnlySpan<byte> -> System.Text.Json.JsonElement
Public Function GetProperty (utf8PropertyName As ReadOnlySpan(Of Byte)) As JsonElement

参数

utf8PropertyName
ReadOnlySpan<Byte>

要返回的属性名称的 UTF-8 表示形式(没有字节顺序标记 (BOM))。The UTF-8 representation (with no Byte-Order-Mark (BOM)) of the name of the property to return.

返回

JsonElement

一个 JsonElement,它表示所需属性的值。A JsonElement representing the value of the requested property.

例外

此值的 ValueKind 不是 ObjectThis value's ValueKind is not Object.

找不到带有所请求名称的属性。No property was found with the requested name.

已释放父级 JsonDocumentThe parent JsonDocument has been disposed.

注解

属性名称匹配作为序号、区分大小写的比较来执行。Property name matching is performed as an ordinal, case-sensitive comparison.

如果为同一对象多次定义某个属性,则该方法将匹配最后一个此类定义。If a property is defined multiple times for the same object, the method matches the last such definition.

有关详细信息,请参阅 如何在上编写自定义序列化程序和反 System.Text.JsFor more information, see How to write custom serializers and deserializers with System.Text.Json.

适用于

GetProperty(ReadOnlySpan<Char>)

获取一个 JsonElement,它表示由 propertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by propertyName.

public:
 System::Text::Json::JsonElement GetProperty(ReadOnlySpan<char> propertyName);
public System.Text.Json.JsonElement GetProperty (ReadOnlySpan<char> propertyName);
member this.GetProperty : ReadOnlySpan<char> -> System.Text.Json.JsonElement
Public Function GetProperty (propertyName As ReadOnlySpan(Of Char)) As JsonElement

参数

propertyName
ReadOnlySpan<Char>

要返回其值的属性的名称。The name of the property whose value is to be returned.

返回

JsonElement

一个 JsonElement,它表示所需属性的值。A JsonElement representing the value of the requested property.

例外

此值的 ValueKind 不是 ObjectThis value's ValueKind is not Object.

找不到带有所请求名称的属性。No property was found with the requested name.

已释放父级 JsonDocumentThe parent JsonDocument has been disposed.

注解

属性名称匹配作为序号、区分大小写的比较来执行。Property name matching is performed as an ordinal, case-sensitive comparison.

如果为同一对象多次定义某个属性,则该方法将匹配最后一个此类定义。If a property is defined multiple times for the same object, the method matches the last such definition.

适用于

GetProperty(String)

获取一个 JsonElement,它表示由 propertyName 标识的所需属性的值。Gets a JsonElement representing the value of a required property identified by propertyName.

public:
 System::Text::Json::JsonElement GetProperty(System::String ^ propertyName);
public System.Text.Json.JsonElement GetProperty (string propertyName);
member this.GetProperty : string -> System.Text.Json.JsonElement
Public Function GetProperty (propertyName As String) As JsonElement

参数

propertyName
String

要返回其值的属性的名称。The name of the property whose value is to be returned.

返回

JsonElement

一个 JsonElement,它表示所需属性的值。A JsonElement representing the value of the requested property.

例外

此值的 ValueKind 不是 ObjectThis value's ValueKind is not Object.

找不到带有所请求名称的属性。No property was found with the requested name.

propertyNamenullpropertyName is null.

已释放父级 JsonDocumentThe parent JsonDocument has been disposed.

注解

属性名称匹配作为序号、区分大小写的比较来执行。Property name matching is performed as an ordinal, case-sensitive comparison.

如果为同一对象多次定义某个属性,则该方法将匹配最后一个此类定义。If a property is defined multiple times for the same object, the method matches the last such definition.

适用于