Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Fengtao1314520 opened this issue Dec 8, 2023 · 2 comments
Closed

Comments

@Fengtao1314520
Copy link

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.

@jchannon
Copy link
Member

jchannon commented Dec 8, 2023 via email

@jchannon
Copy link
Member

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants