Early Preview
This is currently very much a preview. Please feel free to try things out,
but don't be upset if anything is not yet working. Feedback is welcome over on our
GitHub Dicussions page.
struct System.​Text.​Json.​JsonEncodedText
Assembly: System.Text.Json
Implemented Interfaces
Provides methods to transform UTF-8 or UTF-16 encoded text into a form that is suitable for JSON.
Properties
public
ReadOnlySpan<​byte>
EncodedUtf8Bytes
Gets the UTF-8 encoded representation of the pre-encoded JSON text.
public
string
Value
Gets the UTF-16 encoded representation of the pre-encoded JSON text as a <see cref="T:System.String" /> .
Methods
public static
JsonEncodedText
Encode​(ReadOnlySpan<​byte> utf8Value,
Encodings.​Web.​JavaScriptEncoder? encoder = null)
Encodes a UTF-8 text value as a JSON string.
Returns The encoded JSON text.
utf8Value
The UTF-8 encoded text to convert to JSON encoded text.
encoder
The encoder to use when escaping the string, or <see langword="null" /> to use the default encoder.
public static
JsonEncodedText
Encode​(ReadOnlySpan<​char> value,
Encodings.​Web.​JavaScriptEncoder? encoder = null)
Encodes a specified text value as a JSON string.
Returns The encoded JSON text.
value
The value to convert to JSON encoded text.
encoder
The encoder to use when escaping the string, or <see langword="null" /> to use the default encoder.
public static
JsonEncodedText
Encode​(string value,
Encodings.​Web.​JavaScriptEncoder? encoder = null)
Encodes the string text value as a JSON string.
Returns The encoded JSON text.
value
The value to convert to JSON encoded text.
encoder
The encoder to use when escaping the string, or <see langword="null" /> to use the default encoder.
public
bool
Equals​(object obj)
Determines whether this instance and a specified object, which must also be a <see cref="T:System.Text.Json.JsonEncodedText" /> instance, have the same value.
Returns <see langword="true" /> if the current instance and <paramref name="obj" /> are equal; otherwise, <see langword="false" /> .
obj
The object to compare to this instance.
public
bool
Equals​(JsonEncodedText other)
Determines whether this instance and another specified <see cref="T:System.Text.Json.JsonEncodedText" /> instance have the same value.
Returns <see langword="true" /> if this instance and <paramref name="other" /> have the same value; otherwise, <see langword="false" /> .
other
The object to compare to this instance.
public
int
GetHashCode​()
Returns the hash code for this <see cref="T:System.Text.Json.JsonEncodedText" /> .
Returns The hash code for this instance.
public
string
ToString​()
Converts the value of this instance to a <see cref="T:System.String" /> .
Returns The underlying UTF-16 encoded string.
protected
void
Finalize​()
Inherited from object
protected
object
MemberwiseClone​()
Inherited from object