Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
WCF Rest服务日期格式json post get_Json_Wcf - Fatal编程技术网

WCF Rest服务日期格式json post get

WCF Rest服务日期格式json post get,json,wcf,Json,Wcf,这是我的上下文类和接口 [DataContract] public class RatingsTransaction { public DateTime ServerDate; [Key] [DataMember] public Int32 RatID { get; set; } [DataMember]

这是我的上下文类和接口

        [DataContract]
        public class RatingsTransaction
        {
            public DateTime ServerDate;
            [Key]
            [DataMember]
            public Int32 RatID { get; set; }
            [DataMember]
            public Int32 RatingID { get; set; }
            [DataMember]
            public Int32 TransportID { get; set; }
            [DataMember]
            public Int32 UserID { get; set; }
            [DataMember]
            public Boolean IsActive { get; set; }
            [DataMember]
            public Int32 CreatedBy { get; set; }
            [DataMember]
            public DateTime CreatedDate { get { return ServerDate; } set { ServerDate = DateTime.Now; } }
            [DataMember]
            public Int32 ModifiedBy { get; set; }
            [DataMember]
            public DateTime ModifiedDate { get { return ServerDate; } set { ServerDate = DateTime.Now; } }
        }

        [OperationContract]
        [WebGet(UriTemplate = "ratingstransaction/{ID}")]
        RatingsTransaction getRatingsTransaction(string ID);

        public RatingsTransaction getRatingsTransaction(string ID)
        {
            try
            {
                Int32 _id = Convert.ToInt32(ID);
                using (var _WDSObj = new WDS_MODEL())
                {
                    return _WDSObj._RatingsTransaction.SingleOrDefault(p => p.RatID == _id);
                }
            }
            catch (Exception ex)
            {

                throw new FaultException(ex.Message);
            }
        }
当我呼叫此服务时

输出:

{"getRatingsTransactionResult":{"CreatedBy":13,"CreatedDate":"\/Date(1433159097577+0530)\/","IsActive":true,"ModifiedBy":13,"ModifiedDate":"\/Date(1433159097577+0530)\/","RatID":3,"RatingID":3,"TransportID":3,"UserID":240}}

预期日期的格式不正确..如何解决此问题。请建议

这是
json
日期格式。当你
反序列化它为C类型时,应该可以工作。需要以下日期输出来发送移动应用程序:
{“getRatingsTransactionResult”:{“CreatedBy”:13,“CreatedDate”:“2015-05-20”,“IsActive”:true,“ModifiedBy”:13,“ModifiedDate”:“2015-05-20”,“RatID”:3,“RatingID”:3,“TransportID”:3,“UserID”:240}
在这种情况下,将
日期时间
字段更改为
字符串
,并按此格式为其赋值。应该可以。这有助于解决问题吗?