I have a working WCF service that used JSON as RequestFormat and ResponseFormat.
[ServiceContract]
public interface IServiceJSON
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json)]
MyClassA echo(MyClassA oMyObject);
}
[DataContract]
public class MyClassA
{
[DataMember]
public string message;
[DataMember]
public List<MyClassB> myList;
public MyClassA()
{
myList = new List<MyClassB>();
}
}
[DataContract]
public class MyClassB
{
[DataMember]
public int myInt;
[DataMember]
public double myDouble;
[DataMember]
public bool myBool;
[DataMember]
public DateTime myDateTime;
}
The myDateTime property of MyClassB is of type DateTime. This is serialized in the following format: "myDateTime": "/ Date (1329919837509 + 0100) /"
A client with whom I need to communicate cannot work with this format. This requires a more conventional format, for example, for example: yyyy-MM-dd hh: mm: ss
Can this be added to the DataMember attribute? For instance:
[DataMember format = "yyyy-MM-dd hh:mm:ss"]
public DateTime myDateTime;
Thanks in advance!
source
share