diff --git a/docs/core/whats-new/dotnet-8.md b/docs/core/whats-new/dotnet-8.md index f19148498a086..938fef7ce2420 100644 --- a/docs/core/whats-new/dotnet-8.md +++ b/docs/core/whats-new/dotnet-8.md @@ -173,7 +173,7 @@ For example, consider the following code that deserializes into a `CustomerInfo` using System.Text.Json; CustomerInfo customer = - JsonSerializer.Deserialize("""{"Name":"John Doe","Company":{"Name":"Contoso"}}""")!; + JsonSerializer.Deserialize("""{"Names":["John Doe"],"Company":{"Name":"Contoso"}}""")!; Console.WriteLine(JsonSerializer.Serialize(customer)); @@ -187,21 +187,21 @@ class CompanyInfo class CustomerInfo { // Both of these properties are read-only. - public string Name { get; } = "Anonymous"; + public List Names { get; } = new(); public CompanyInfo Company { get; } = new() { Name = "N/A", PhoneNumber = "N/A" }; } ``` -Prior to .NET 8, the input values were ignored and the `Name` and `Company` properties retained their default values. +Prior to .NET 8, the input values were ignored and the `Names` and `Company` properties retained their default values. ```output -{"Name":"Anonymous","Company":{"Name":"N/A","PhoneNumber":"N/A"}} +{"Names":[],"Company":{"Name":"N/A","PhoneNumber":"N/A"}} ``` Now, the input values are used to populate the read-only properties during deserialization. ```output -{"Name":"John Doe","Company":{"Name":"Contoso","PhoneNumber":null}} +{"Names":["John Doe"],"Company":{"Name":"Contoso","PhoneNumber":null}} ``` #### Disable reflection-based default