In our web API we have legacy entities that have abbreviated names. We are also using code generation via T4 templates, where we like to keep things simple and predictable:
- Template creates C# classes and capitalize the first character of the properties
- Template creates Angular code and lowercase the first character of the properties
The JSON response from the web API however does some magic on deciding which letters to convert to lowercase, instead of only the expected first character.
For example, when starting a new default web API in Visual Studio and adding two properties to the WeatherForecast.cs
:
public string TSTValue { get; set; }
public string TSTVL1 { get; set; }
The result is:
[
{
...
"tstValue":null,
"tstvL1":null
},
{
...
"tstValue":null,
"tstvL1":null
}
]
The expected/desired output would be a result with the camelcase property names:
[
{
...
"tSTValue":null,
"tSTVL1":null
},
{
...
"tSTValue":null,
"tSTVL1":null
}
]
How can the magic behavior be overridden?