下面有一个json结构,其格式随每个请求而变化,并将其作为POST有效负载发送到.Net MVC 4。
{"id":40388111,"parameters":[{"fid":40388138,"all":true,"isaccounts":true},{"fid":40388139,"value":"2014-10-02T00:00:00.000Z"}],"output":"json","start":0,"limit":25}
控制器操作如下:
[HttpPost]
public async Task<HttpResponseMessage> Execute(dynamic payload)
{
string postData = Convert.ToString(payload);
var vm = await _service.Execute(postData);
return Request.CreateResponse(HttpStatusCode.OK, vm, new MediaTypeHeaderValue("application/json"));
}
问题是字符串postData变为:
{
"id": 40388111,
"parameters": [
{
"fid": 40388138,
"all": true,
"isaccounts": true
},
{
"fid": 40388139,
"value": "2014-10-02T00:00:00Z"
}
],
"output": "json",
"start": 0,
"limit": 25
}
您会注意到日期中缺少的毫秒数,这会导致接收此postData字符串的服务中出现问题。如何使postData字符串日期与传入的有效内容日期格式相同?