JavaScriptEncoder.UnsafeRelaxedJsonEscaping Property

Definition

Gets a built-in JavaScript encoder instance that is less strict about what is encoded.

public static System.Text.Encodings.Web.JavaScriptEncoder UnsafeRelaxedJsonEscaping { get; }

Property Value

A JavaScript encoder instance.

Remarks

Unlike the Default encoder, this encoder instance does not escape HTML-sensitive characters such as <, >, &. As a result, it must be used cautiously; for example, it can be used if the output data is within a response whose content-type is known with a charset set to UTF-8.

Unlike the Default encoding, the quotation mark is encoded as \" rather than \u0022.

Unlike the Default encoding (which only allows UnicodeRanges.BasicLatin), using this encoder instance allows UnicodeRanges.All to go through unescaped.

Unlike the Default encoder, this encoder instance allows some other characters (such as '+') to go through unescaped and therefore must be used cautiously.

For more information about why this could be unsafe, see Serialize all characters.

Applies to

Product Versions
.NET Core 3.0, Core 3.1, 5, 6, 7, 8 (package-provided), 8, 9 (package-provided), 9
.NET Framework 4.7 (package-provided), 4.7.1 (package-provided), 4.7.2 (package-provided), 4.8 (package-provided)
.NET Standard 2.0 (package-provided)