Edit

Share via


JsonMarshal.GetRawUtf8Value(JsonElement) Method

Definition

Gets a ReadOnlySpan<T> view over the raw JSON data of the given JsonElement.

public:
 static ReadOnlySpan<System::Byte> GetRawUtf8Value(System::Text::Json::JsonElement element);
public static ReadOnlySpan<byte> GetRawUtf8Value(System.Text.Json.JsonElement element);
static member GetRawUtf8Value : System.Text.Json.JsonElement -> ReadOnlySpan<byte>
Public Shared Function GetRawUtf8Value (element As JsonElement) As ReadOnlySpan(Of Byte)

Parameters

element
JsonElement

The JSON element from which to extract the span.

Returns

The span containing the raw JSON data ofelement.

Exceptions

The underlying JsonDocument has been disposed.

Remarks

While the method itself does check for disposal of the underlying JsonDocument, it is possible that it could be disposed after the method returns, which would result in the span pointing to a buffer that has been returned to the shared pool. Callers should take extra care to make sure that such a scenario isn't possible to avoid potential data corruption.

Applies to