I've got the following class:
[DataContractAttribute]
public class TestClass
{
[DataMemberAttribute]
public DateTime MyDateTime { get; set; }
}
Here's the JSON:
{ "MyDateTime":"1221818565" }
The JSON is being returned from a PHP webservice.
What I need to do, is convert that epoch string into a valid C# DateTime. What's the best way of doing this?
I can do this:
[IgnoreDataMemberAttribute]
public DateTime MyDateTime { get; set; }
[DataMemberAttribute(Name = "MyDateTime")]
public Int32 MyDateTimeTicks
{
get { return this.MyDateTime.Convert(...); }
set { this.Created = new DateTime(...); }
}
But the trouble with this is, the MyDateTimeTicks is public (changing it to private causes an exception in the serialization process)