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

System.Text.Json.JsonEncodedText

Provides methods to transform UTF-8 or UTF-16 encoded text into a form that is suitable for JSON.
namespace System.Text.Json { public readonly struct JsonEncodedText : IEquatable<JsonEncodedText> { public ReadOnlySpan<byte> EncodedUtf8Bytes { get; } public string Value { get; } public static JsonEncodedText Encode(string value, JavaScriptEncoder encoder = null); public static JsonEncodedText Encode(ReadOnlySpan<char> value, JavaScriptEncoder encoder = null); public static JsonEncodedText Encode(ReadOnlySpan<byte> utf8Value, JavaScriptEncoder encoder = null); public bool Equals(JsonEncodedText other); } }