As noted in the past, Microsoft really really really likes to mess with your data. They think it's fun to take a property you have defined, let's say FirstName, and change that property to firstName when returning JSON data. Why? Because you are stupid of course and Microsoft is soooo smart...Actually it's because Microsoft is soooo stupid.
I get it. Some people like Camel Case. If you do, great. If you want to name your fields that way, great. If you want to add a JSON serialization option to update non camel case to camel case, great. But it is egregious for a technology company to, by default, change your field names. And I hates them for it.
If you come across this egregious error by Microsoft, you can fix it by adding a Startup.cs file to your project and removing the default "we think we are soooo smart" renaming convention.
- Add Nuget Package: Microsoft.AspNetCore.Mvc.NewtonsoftJson
- Add Startup.cs file to the root of your project.
- Update the Startup.cs file.
//Startupt.cs
using Microsoft.Azure.Functions.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
[assembly: FunctionsStartup(typeof(MyNamespace.Startup))]
namespace MyNamespace
{
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
builder.Services.AddMvcCore().AddNewtonsoftJson(options =>
{
options.UseMemberCasing();
});
}
}
}