the default WebApi template for ASP.NET 3.1 produces a service that returns weather forecasts in camel-cased JSON format.
If I want to consume this service in an ASP.NET 3.1 web application, but have no access to the web service, how do I deserialize the camel-cased JSON into an object that is pascal-cased?
So deseialize this WebAPI output:
{
"date": "2020-10-14T13:45:55.9398376+01:00",
"temperatureC": 43,
"temperatureF": 109,
"summary": "Bracing"
}
to this object:
public class WeatherForecast
{
public DateTime Date { get; set; }
public int TemperatureC { get; set; }
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
public string Summary { get; set; }
}
If I had access to both service and site it's a simple matter of setting the JSON contract resolver.