.NET: Microsoft Technologies based on the .NET software framework. Runtime: An environment required to run apps that aren't compiled to machine language.
The official .NET 10 API reference directly supports the statement that SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions) returns a byte[] containing the value’s JSON representation encoded as UTF-8.^1^
Applicable .NET 10 contract
The relevant C# signature is:
public static byte[] SerializeToUtf8Bytes<TValue>(
TValue value,
JsonSerializerOptions? options = default);
On the view=net-10.0 page, the overload is identified as:
SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions)
Its description says that it converts the generically typed value into a JSON string encoded as UTF-8 bytes, and its Returns entry states:
A JSON string representation of the value, encoded as UTF-8 bytes.
Most importantly for version scope, the overload’s surrounding moniker range explicitly includes net-10.0. Therefore, both the overload and that return description are documented as applying to .NET 10.^1^
The general serialization guide independently confirms the operational part of the contract: to serialize to a UTF-8 byte array, call JsonSerializer.SerializeToUtf8Bytes.^2^
var value = new { Name = "Ada", Active = true };
byte[] jsonUtf8Bytes =
JsonSerializer.SerializeToUtf8Bytes(value);
string json = Encoding.UTF8.GetString(jsonUtf8Bytes);
// {"Name":"Ada","Active":true}
Which displayed signature variant to cite
For C# on .NET 10, cite the nullable-options form:
public static byte[] SerializeToUtf8Bytes<TValue>(
TValue value,
JsonSerializerOptions? options = default);
The API page can display several declarations because one article aggregates supported target frameworks, languages, annotations, and API versions. Those alternatives should not be combined into a new signature. For the requested claim, the decisive elements are:
- the generic overload taking
TValueandJsonSerializerOptions; - its
byte[]return type; - its return description;
- the moniker range containing
net-10.0.
Meaning of the System.Text.Json v11.0.0 banner
The page-level Package: System.Text.Json v11.0.0 entry identifies package metadata represented on the aggregated API page; it does not cancel the overload-level net-10.0 applicability marker.
Microsoft distinguishes a NuGet package version from other library versions and states that a NuGet package version is used by NuGet and has no effect on runtime behavior.^3^ Consequently, the package banner and prerelease notice should not be used alone to establish the .NET 10 contract—but neither should they be read as excluding .NET 10 when the overload’s moniker explicitly includes net-10.0.
A concise citation-ready statement is:
In .NET 10,
JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions?)returns abyte[]containing a JSON string representation of the supplied value encoded as UTF-8.^1^
References