Modifier

Partager via


JsonEncodedText.Encode Method

Definition

Overloads

Encode(ReadOnlySpan<Byte>, JavaScriptEncoder)

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

Encode(ReadOnlySpan<Char>, JavaScriptEncoder)

Encodes a specified text value as a JSON string.

Encode(String, JavaScriptEncoder)

Encodes the string text value as a JSON string.

Encode(ReadOnlySpan<Byte>, JavaScriptEncoder)

Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs

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);
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 = Nothing) As JsonEncodedText

Parameters

utf8Value
ReadOnlySpan<Byte>

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.

Returns

The encoded JSON text.

Exceptions

utf8Value is too large.

-or-

utf8Value contains invalid UTF-8 bytes.

Applies to

Encode(ReadOnlySpan<Char>, JavaScriptEncoder)

Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs

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);
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 = Nothing) As JsonEncodedText

Parameters

value
ReadOnlySpan<Char>

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.

Returns

The encoded JSON text.

Exceptions

value is too large.

-or-

value contains invalid UTF-16 characters.

Applies to

Encode(String, JavaScriptEncoder)

Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs
Source:
JsonEncodedText.cs

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);
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 = Nothing) As JsonEncodedText

Parameters

value
String

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.

Returns

The encoded JSON text.

Exceptions

value is null.

value is too large.

-or-

value contains invalid UTF-16 characters.

Applies to