AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

.NET 7 update required: JSON options configuration

Open Rick-Anderson opened this issue 3 years ago • 0 comments

JSON options configuration

ConfigureRouteHandlerJsonOptions has been renamed ConfigureHttpJsonOptions, see https://github.com/dotnet/aspnetcore/pull/42747

Need to update the following code for next release:

using System.Text.Json.Serialization;

var builder = WebApplication.CreateBuilder(args);

builder.Services.ConfigureRouteHandlerJsonOptions(options =>
{
    options.SerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
    options.SerializerOptions.AllowTrailingCommas = true;
    options.SerializerOptions.MaxDepth = 8;
});

var app = builder.Build();

app.MapGet("/", () => "Hello World!");

app.Run();

Rick-Anderson avatar Jul 16 '22 01:07 Rick-Anderson