<PackageReference Include="System.Text.Json" Version="9.0.0" />

JsonEncodedText

Provides methods to transform UTF-8 or UTF-16 encoded text into a form that is suitable for JSON.
public ReadOnlySpan<byte> EncodedUtf8Bytes { get; }

Gets the UTF-8 encoded representation of the pre-encoded JSON text.

public string Value { get; }

Gets the UTF-16 encoded representation of the pre-encoded JSON text as a String.

public static JsonEncodedText Encode(string value, JavaScriptEncoder encoder = null)

Encodes the string text value as a JSON string.

public static JsonEncodedText Encode(ReadOnlySpan<char> value, JavaScriptEncoder encoder = null)

Encodes a specified text value as a JSON string.

public static JsonEncodedText Encode(ReadOnlySpan<byte> utf8Value, JavaScriptEncoder encoder = null)

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

public bool Equals(JsonEncodedText other)

Determines whether this instance and another specified JsonEncodedText instance have the same value.