According to https://learn.microsoft.com/en-us/aspnet/core/web-api/advanced/formatting?view=aspnetcore-5.0 CamelCase should be the default formatting for System.Text.Json.
I am however getting PascalCase i.e. first char is a capital.
I tried adding
services.AddControllers().AddJsonOptions(option => option.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase);
to Startup, which as expected made no difference.
If I add
var options = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
};
return Ok(JsonSerializer.Serialize(collection, options));
to the specific serialiser then I get camelCase i.e. first char lower case.
Anyone else seen this? Am I using it wrong?