CarterCommunity / Carter

Carter is framework that is a thin layer of extension methods and functionality over ASP.NET Core allowing code to be more explicit and most importantly more enjoyable.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to change the field of the response data body to uppercase

Fengtao1314520 opened this issue · comments

when i use our library, i had set

builder.Services.AddCarter();
builder.Services.AddControllers() .AddJsonOptions(options => options.JsonSerializerOptions.PropertyNamingPolicy = null);
but output still keep lowcase for first word, like this
"userStatus": "active",
I need uppercase
"UserStatus": "active",

I have to changed respone code like this
return Results.Json(result, new JsonSerializerOptions { PropertyNamingPolicy = null });

it can be work, but not i hoped method, i think must have other method can solve it.

You could also define json serializer options using the below, either approaches will work

x.ConfigureHttpJsonOptions(jsonOptions =>
                        {
                            jsonOptions.SerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.KebabCaseUpper;
                        });