I've migrated a web api application from net core 5 to 6 and changed NewtonSoft serializer by System.Text.Json. In my Startup.cs, I've configured Json serialization with the following code:
services.AddControllers(config =>
{
config.RespectBrowserAcceptHeader = true;
config.ReturnHttpNotAcceptable = true;
})
.AddJsonOptions(options =>
{
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.WriteIndented = true;
})
.AddXmlDataContractSerializerFormatters();
This code is working only partially. WriteIndented is working fine (see screen capture below), but I can't get camelcase to work.
Any suggestions? Regards