-
-
Notifications
You must be signed in to change notification settings - Fork 786
Closed
Labels
Milestone
Description
Is your feature request related to a problem? Please describe.
I would like to override the JSON serializer options which seem to be hard coded in HttpResponseExtensions. It would be nice to indent the JSON in dev/test for easier debugging.
Describe the solution you'd like
ASP.NET Core provides a way to override the JSON options e.g. I use this in my Swagger API:
builder.AddJsonOptions(
options =>
{
var jsonSerializerOptions = options.JsonSerializerOptions;
if (webHostEnvironment.IsDevelopment() ||
webHostEnvironment.IsEnvironment("Test"))
{
// Pretty print the JSON in development/test for easier debugging.
jsonSerializerOptions.WriteIndented = true;
}
jsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
jsonSerializerOptions.DictionaryKeyPolicy = JsonNamingPolicy.CamelCase;
jsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
});
ac10n, TastyDucks, jobadder-daviddancy, aholmis and tylermichaelaaron-manning