Consider the following json string given:
{
"items":
[
{
...,
"view_count":4,
"answer_count":0,
"score":0,
"last_activity_date":1445071150
}
],
...
}
Is there a way to have last_activity_date deserialized as instance of another type using System.Runtime.Serialization.DataContractAttribute and System.Runtime.Serialization.Json.DataContractJsonSerializer?
E.g.: 1445071150 -> Date where Date is
[System.Runtime.Serialization.DataContract]
public class Date
{
[System.Runtime.Serialization.IgnoreDataMember]
public long ElapsedSeconds { get; set; }
[System.Runtime.Serialization.IgnoreDataMember]
public DateTime Date { get { ... } set; }
public Date(long seconds)
{
ElapsedSeconds = seconds;
Date = ...;
}
public static implicit operator Date(long seconds)
{
return new Date(seconds);
}
// Other members ...
}
IContractResolver: newtonsoft.com/json/help/html/contractresolver.htm and use OwnConverterfor that.