JsonEncodedText.Encode 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
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
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
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
.