WCF服务中Json数据输出DateTime如何格式化?

In WCF Service Json Data Output DateTime How to be Formatted?

在 wcf 中使用 Mongodb 我得到 json 数据,我的输出是这样的

{
    "JobSearchResult":"[{\"JobId\":\"JO1101\",
    **\"ExpiryDate\":\"\\/Date(1737538921565)\\/\",**
    \"Location\":\"Mumbai\",
    \"Experience\":\"1-6Year\"}]",
    "Count":1,"status":1
 }

查看 ExpiryDate,它采用 mongodb 格式,我必须像这样输出 Date(25/02/2015) ..以及如何删除 json ouput[=13= 中的反斜杠]

我认为您使用 linq 从 wcf 中的 mongodb 获取值。所以你在 (25/02/2015) 中询问这种类型格式作为输出中的日期。

请做两件事

1) 在class

中将数据类型更改为字符串
public string Date { get; set;}

2) 获取输出对象日期作为这种格式

Date = String.Format("{0:dd-MM-yyyy}", obj.Date).ToString(),

你一定会得到 25/02/2015。