JsonElement.TryGetProperty 方法
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
重载
TryGetProperty(String, JsonElement) |
查找当前对象中名为 |
TryGetProperty(ReadOnlySpan<Byte>, JsonElement) |
查找当前对象中名为 |
TryGetProperty(ReadOnlySpan<Char>, JsonElement) |
查找当前对象中名为 |
TryGetProperty(String, JsonElement)
查找当前对象中名为 propertyName
的属性,返回一个指示此类属性是否存在的值。 如果此属性存在,会将其值分配给 value
参数。
public:
bool TryGetProperty(System::String ^ propertyName, [Runtime::InteropServices::Out] System::Text::Json::JsonElement % value);
public bool TryGetProperty (string propertyName, out System.Text.Json.JsonElement value);
member this.TryGetProperty : string * JsonElement -> bool
Public Function TryGetProperty (propertyName As String, ByRef value As JsonElement) As Boolean
参数
- propertyName
- String
要查找的属性的名称。
- value
- JsonElement
此方法返回时,包含指定属性的值。
返回
如果找到该属性,则为 true
;否则为 false
。
例外
propertyName
为 null
。
注解
属性名称匹配作为序号、区分大小写的比较执行。
如果为同一对象多次定义属性,该方法将匹配最后一个此类定义。
适用于
TryGetProperty(ReadOnlySpan<Byte>, JsonElement)
查找当前对象中名为 utf8PropertyName
的属性,返回一个指示此类属性是否存在的值。 如果此属性存在,该方法会将其值分配给 value
参数。
public:
bool TryGetProperty(ReadOnlySpan<System::Byte> utf8PropertyName, [Runtime::InteropServices::Out] System::Text::Json::JsonElement % value);
public bool TryGetProperty (ReadOnlySpan<byte> utf8PropertyName, out System.Text.Json.JsonElement value);
member this.TryGetProperty : ReadOnlySpan<byte> * JsonElement -> bool
Public Function TryGetProperty (utf8PropertyName As ReadOnlySpan(Of Byte), ByRef value As JsonElement) As Boolean
参数
- utf8PropertyName
- ReadOnlySpan<Byte>
要返回的属性名称的 UTF-8 表示形式(没有字节顺序标记 (BOM))。
- value
- JsonElement
接收已找到的属性的值。
返回
如果找到该属性,则为 true
;否则为 false
。
例外
注解
属性名称匹配作为序号、区分大小写的比较执行。
如果为同一对象多次定义属性,该方法将匹配最后一个此类定义。
有关详细信息,请参阅 如何使用 System.Text.Json 编写自定义序列化程序和反序列化程序。
适用于
TryGetProperty(ReadOnlySpan<Char>, JsonElement)
查找当前对象中名为 propertyName
的属性,返回一个指示此类属性是否存在的值。 如果此属性存在,该方法会将其值分配给 value
参数。
public:
bool TryGetProperty(ReadOnlySpan<char> propertyName, [Runtime::InteropServices::Out] System::Text::Json::JsonElement % value);
public bool TryGetProperty (ReadOnlySpan<char> propertyName, out System.Text.Json.JsonElement value);
member this.TryGetProperty : ReadOnlySpan<char> * JsonElement -> bool
Public Function TryGetProperty (propertyName As ReadOnlySpan(Of Char), ByRef value As JsonElement) As Boolean
参数
- propertyName
- ReadOnlySpan<Char>
要查找的属性的名称。
- value
- JsonElement
此方法返回时,包含指定属性的值。
返回
如果找到该属性,则为 true
;否则为 false
。
例外
注解
属性名称匹配作为序号、区分大小写的比较执行。
如果为同一对象多次定义属性,该方法将匹配最后一个此类定义。