JsonElement.TryGetProperty Method
Definition
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.
Overloads
TryGetProperty(String, JsonElement) |
Looks for a property named |
TryGetProperty(ReadOnlySpan<Byte>, JsonElement) |
Looks for a property named |
TryGetProperty(ReadOnlySpan<Char>, JsonElement) |
Looks for a property named |
TryGetProperty(String, JsonElement)
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
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(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
Parameters
- propertyName
- String
The name of the property to find.
- value
- JsonElement
When this method returns, contains the value of the specified property.
Returns
true
if the property was found; otherwise, false
.
Exceptions
propertyName
is null
.
The parent JsonDocument has been disposed.
Remarks
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.
Applies to
TryGetProperty(ReadOnlySpan<Byte>, JsonElement)
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
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 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
Parameters
- utf8PropertyName
- ReadOnlySpan<Byte>
The UTF-8 (with no Byte-Order-Mark (BOM)) representation of the name of the property to return.
- value
- JsonElement
Receives the value of the located property.
Returns
true
if the property was found; otherwise, false
.
Exceptions
The parent JsonDocument has been disposed.
Remarks
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.
For more information, see How to write custom serializers and deserializers with System.Text.Json.
Applies to
TryGetProperty(ReadOnlySpan<Char>, JsonElement)
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
- Source:
- JsonElement.cs
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<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
Parameters
- propertyName
- ReadOnlySpan<Char>
The name of the property to find.
- value
- JsonElement
When this method returns, contains the value of the specified property.
Returns
true
if the property was found; otherwise, false
.
Exceptions
The parent JsonDocument has been disposed.
Remarks
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.