.NET 10 documentation for SerializeToUtf8Bytes

Manica Moscon Advogados 5 Reputation points
2026-11-12T18:20:52.41+00:00

Could you point me to an official reference that establishes what applies to .NET 10 for the System.Text.Json.JsonSerializer.SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions) overload? The specific statement I’d like to verify is that this overload returns a byte[] containing the JSON representation of the supplied value encoded in UTF-8.

In one retrieval of the Microsoft Learn URL requesting the .NET 10 view, the returned text included the section for this overload. The header listed System.Text.Json v11.0.0 and displayed a prerelease notice, and the section showed multiple signature variants. That left me unsure which parts of the returned section I could cite as applying to .NET 10. Microsoft Learn method reference

An official reference that supports only part of the return statement would be useful. If the reference also identifies which signature variant applies, please indicate the variant it supports. If the package header affects how the section should be read for this specific claim, a brief clarification on that point would help. The goal is to establish the scope of the documented return statement for this overload.

Developer technologies | .NET | .NET Runtime

2 answers

Sort by: Newest
  1. Nguyen Dam (WICLOUD CORPORATION) 1,420 Reputation points Microsoft External Staff Moderator
    2026-11-13T09:20:39.6066667+00:00

    Hello @Manica Moscon Advogados and thank you for reaching out.

    The relevant source is the official JsonSerializer.xml file in the dotnet-api-docs repository.

    For SerializeToUtf8Bytes<TValue>(TValue, JsonSerializerOptions), the relevant XML member is around lines 5874–5937.

    A few details are worth distinguishing:

    • The <AssemblyInfo> section includes 10.0.0.0.
    • The C# <MemberSignature> declares the return type as byte[].
    • The <ReturnValue> section declares System.Byte[].
    • The <Docs><returns> element states: "A JSON string representation of the value, encoded as UTF-8 bytes."

    The FrameworkAlternate entries containing net-10.0 appear on the attributes and parameter metadata, not directly on the <returns> element.

    Therefore, I would avoid claiming that a specific FrameworkAlternate range directly scopes the Returns description. The XML provides the return description as shared member documentation, while the assembly metadata and the generated API reference establish the method's applicability to .NET 10.

    You can also verify the generated reference here: JsonSerializer.SerializeToUtf8Bytes Method (.NET 10)

    Regarding the System.Text.Json v11.0.0 package header: it identifies package metadata on the aggregated API page. It should not, by itself, be interpreted as evidence that the displayed method documentation applies exclusively to .NET 11. The .NET 10 applicability is independently represented in the API reference.

    If you found my response helpful or informative, I would greatly appreciate it if you could follow this guide for your confirmation. Thank you. 

    Was this answer helpful?

    0 comments No comments

  2. AI answer

    2026-11-12T18:22:45.6866667+00:00

    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 TValue and JsonSerializerOptions;
    • 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 a byte[] containing a JSON string representation of the supplied value encoded as UTF-8.^1^


    References

    1. JsonSerializer.SerializeToUtf8Bytes Method
    2. How to write .NET objects as JSON (serialize)
    3. Versioning
    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.