JsonEncodedText.Encode Метод

Определение

Перегрузки

Encode(ReadOnlySpan<Byte>, JavaScriptEncoder)

Encodes a UTF-8 text value as a JSON string.Encodes a UTF-8 text value as a JSON string.

Encode(ReadOnlySpan<Char>, JavaScriptEncoder)

Encodes a specified text value as a JSON string.Encodes a specified text value as a JSON string.

Encode(String, JavaScriptEncoder)

Encodes the string text value as a JSON string.Encodes the string text value as a JSON string.

Encode(ReadOnlySpan<Byte>, JavaScriptEncoder)

Encodes a UTF-8 text value as a JSON string.Encodes a UTF-8 text value as a JSON string.

public static System.Text.Json.JsonEncodedText Encode (ReadOnlySpan<byte> utf8Value, System.Text.Encodings.Web.JavaScriptEncoder encoder = default);
static member Encode : ReadOnlySpan<byte> * System.Text.Encodings.Web.JavaScriptEncoder -> System.Text.Json.JsonEncodedText
Public Shared Function Encode (utf8Value As ReadOnlySpan(Of Byte), Optional encoder As JavaScriptEncoder = null) As JsonEncodedText

Параметры

utf8Value
ReadOnlySpan<Byte>

The UTF-8 encoded text to convert to JSON encoded text.The UTF-8 encoded text to convert to JSON encoded text.

encoder
JavaScriptEncoder

The encoder to use when escaping the string, or null to use the default encoder.The encoder to use when escaping the string, or null to use the default encoder.

Возвращаемое значение

The encoded JSON text.The encoded JSON text.

Исключения

utf8Value is too large.utf8Value is too large.

-or--or-

utf8Value contains invalid UTF-8 bytes.utf8Value contains invalid UTF-8 bytes.

Encode(ReadOnlySpan<Char>, JavaScriptEncoder)

Encodes a specified text value as a JSON string.Encodes a specified text value as a JSON string.

public static System.Text.Json.JsonEncodedText Encode (ReadOnlySpan<char> value, System.Text.Encodings.Web.JavaScriptEncoder encoder = default);
static member Encode : ReadOnlySpan<char> * System.Text.Encodings.Web.JavaScriptEncoder -> System.Text.Json.JsonEncodedText
Public Shared Function Encode (value As ReadOnlySpan(Of Char), Optional encoder As JavaScriptEncoder = null) As JsonEncodedText

Параметры

value
ReadOnlySpan<Char>

The value to convert to JSON encoded text.The value to convert to JSON encoded text.

encoder
JavaScriptEncoder

The encoder to use when escaping the string, or null to use the default encoder.The encoder to use when escaping the string, or null to use the default encoder.

Возвращаемое значение

The encoded JSON text.The encoded JSON text.

Исключения

value is too large.value is too large.

-or--or-

value contains invalid UTF-16 characters.value contains invalid UTF-16 characters.

Encode(String, JavaScriptEncoder)

Encodes the string text value as a JSON string.Encodes the string text value as a JSON string.

public static System.Text.Json.JsonEncodedText Encode (string value, System.Text.Encodings.Web.JavaScriptEncoder encoder = default);
static member Encode : string * System.Text.Encodings.Web.JavaScriptEncoder -> System.Text.Json.JsonEncodedText
Public Shared Function Encode (value As String, Optional encoder As JavaScriptEncoder = null) As JsonEncodedText

Параметры

value
String

The value to convert to JSON encoded text.The value to convert to JSON encoded text.

encoder
JavaScriptEncoder

The encoder to use when escaping the string, or null to use the default encoder.The encoder to use when escaping the string, or null to use the default encoder.

Возвращаемое значение

The encoded JSON text.The encoded JSON text.

Исключения

value is null.value is null.

value is too large.value is too large.

-or--or-

value contains invalid UTF-16 characters.value contains invalid UTF-16 characters.

Применяется к