I am developing an API to expose some data using ASP.NET Web API.
In one of the API, the client wants us to expose the date in yyyy-MM-dd
format. I don't want to change the global settings (e.g. GlobalConfiguration.Configuration.Formatters.JsonFormatter
) for that since it is very specific to this client. And I do developing that in a solution for multiple clients.
One of the solution that I could think of is to create a custom JsonConverter
and then put that to the property I need to do the custom formatting
e.g.
class ReturnObjectA
{
[JsonConverter(typeof(CustomDateTimeConverter))]
public DateTime ReturnDate { get;set;}
}
Just wondering if there is some other easy way of doing that.