I have 2 sections in my api. One is for newer stuff which I would like to keep outputs as modern/standard as possible. I also have a legacy section that has to talk with old programs, which I can not modify.
The old programs are expecting dates to be in this format.
"EndDateActual":"\/Date(1398272400000+0000)\/"
Currently I'm sending the Date object in this format.
"EndDateActual":"2014-04-23T17:00:00Z"
The dates are being returned from the stored procedure as a string rather than DateTime.
Which is being passed into a Task object that is decorated with the[DataMember]
[DataContract]
properties.
I'm passing everything back as an IEnumerable with the String that is actually a date being one propriety of the Task object.
[DataContract()]
public class Task
{
[DataMember(Order = 1)]
public Guid Id { get; set; }
[DataMember(Order = 2)]
public string StartDateActual { get; set; }
[DataMember(Order = 3)]
public string StartDateProjected { get; set; }
[DataMember(Order = 4)]
public string EndDateActual { get; set; }
[DataMember(Order = 5)]
public string EndDateProjected { get; set; }
I haven't managed to get a sterilizer to work yet. However, will it work due to the EndDateActual being a string?
If possible I would like to make it work this way for the legacy objects and the standard way for the rest of the api, which I am guessing is the default so I would like to avoid Global options. However, I am still new to all this so please correct me if I am wrong.
Thanks in advance!