Skip to content

JsonElement.TryGetBytesFromBase64 Method

Definition

Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Source: JsonElement.cs

TryGetBytesFromBase64(ref byte[])

Attempts to represent the current JSON string as bytes assuming it is Base64 encoded.

public bool TryGetBytesFromBase64(ref byte[] value)

Parameters

Name Type Description
value ref byte[] Receives the value.

Returns

bool

true if the entire token value is encoded as valid Base64 text and can be successfully decoded to bytes. false otherwise.

Exceptions

Exception Description
InvalidOperationException This value's ValueKind is not String.
ObjectDisposedException The parent JsonDocument has been disposed.

Remarks

This method does not create a byte[] representation of values other than base 64 encoded JSON strings.

Applies To

Product Versions
.NET 9, 10
.NET Standard 2.0, 2.1

Collaborate with us on GitHub

The source for this content can be found on GitHub, where you can also create and review issues and pull requests.

Open an issue