JsonEncodedText.Encode Method
Definition
Namespace: Corvus.Text.Json
Assembly: Corvus.Text.Json.dll
Overloads
Encode(string, JavaScriptEncoder)
Source: JsonEncodedText.cs
Encodes the string text value as a JSON string.
public static JsonEncodedText Encode(string value, JavaScriptEncoder encoder)
Parameters
| Name |
Type |
Description |
value |
string |
The value to be transformed as JSON encoded text. |
encoder |
JavaScriptEncoder |
The encoder to use when escaping the string, or null to use the default encoder. (optional) |
Returns
JsonEncodedText
Exceptions
Applies To
| Product |
Versions |
| .NET |
9, 10 |
| .NET Standard |
2.0, 2.1 |
Encode(ReadOnlySpan<char>, JavaScriptEncoder)
Source: JsonEncodedText.cs
Encodes the text value as a JSON string.
public static JsonEncodedText Encode(ReadOnlySpan<char> value, JavaScriptEncoder encoder)
Parameters
| Name |
Type |
Description |
value |
ReadOnlySpan<char> |
The value to be transformed as JSON encoded text. |
encoder |
JavaScriptEncoder |
The encoder to use when escaping the string, or null to use the default encoder. (optional) |
Returns
JsonEncodedText
Exceptions
| Exception |
Description |
ArgumentException |
Thrown when the specified value is too large or if it contains invalid UTF-16 characters. |
Applies To
| Product |
Versions |
| .NET |
9, 10 |
| .NET Standard |
2.0, 2.1 |
Encode(ReadOnlySpan<byte>, JavaScriptEncoder)
Source: JsonEncodedText.cs
Encodes the UTF-8 text value as a JSON string.
public static JsonEncodedText Encode(ReadOnlySpan<byte> utf8Value, JavaScriptEncoder encoder)
Parameters
| Name |
Type |
Description |
utf8Value |
ReadOnlySpan<byte> |
The UTF-8 encoded value to be transformed as JSON encoded text. |
encoder |
JavaScriptEncoder |
The encoder to use when escaping the string, or null to use the default encoder. (optional) |
Returns
JsonEncodedText
Exceptions
| Exception |
Description |
ArgumentException |
Thrown when the specified value is too large or if it contains invalid UTF-8 bytes. |
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