我在Rest服务器中创建了一个get方法,它将以json格式返回数据。 在JSON对象中包含一个日期时间字段,如果我传递这个日期时间字段为空,那么它将通过一个异常。在休息API时,reutrn datetime null以json格式创建错误
这是代码我有,似乎不工作
public class meta
{
private System.DateTime createdField;
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public System.DateTime created {
get { return this.createdField; }
set { this.createdField = value; }
}
}
添加更多细节例如你的示例代码,例外等 – bjan 2012-02-18 06:05:59
你必须使这个字段'Nullable',接受'空'的 – 2012-02-18 06:16:57