Turning off camelCasing, PascalCasing in JSON response from ASP.NET Core 3.1 API

143 0

In ASP.NET Core 3.1 api the default json response formatting is camelCase.

When you have a model in this way

public class EmployeeModel
public int Id { get; set; }
public string FirstName { get; set; }


private static readonly List myEmployeeModel = new List
new EmployeeModel {Id = 1, FirstName = “David zongo”},
new EmployeeModel {Id = 2, FirstName = “Koudbi”, },

The call in a Get
public IEnumerable Get()
return myEmployeeModel;
The result of this call
{"id":1, "firstName":"David zongo"},

As you can see if you want to receive the result with FirstName

Here is the formatting to add under startup.cs:

.AddNewtonsoftJson(options =>

Related Post