我想将我的日期序列化为特定格式,但我无法一起行动。
我尝试构建一个不错的小类,但输出用引号括起来,这是行不通的。
我希望 JSON 看起来像这样......
{
date : new Date(2013, 8, 30)
}
但我明白了……
{
date: "new Date(2013, 8, 30)"
}
我的课
public class DateCell : ChartCell
{
[JsonIgnore]
public DateTime Value { get; set; }
[JsonProperty(PropertyName = "date")]
public override object DataValue
{
get
{
return string.Format("new Date({0}, {1}, {2})", this.Value.Year, this.Value.Month - 1, this.Value.Day);
}
}
}