在webapiConfig.cs
加上以下代码作为配置:
//实现序列化为JSON
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.Converters.Add(new IsoDateTimeConverter {
DateTimeFormat = "yyyy'-'MM'-'dd' 'HH':'mm':'ss"
});
GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ContractResolver =
new CamelCasePropertyNamesContractResolver();
Controller调用:
return Json<dynamic>(new {
success = true,
msg = "OK",
profits = mypf
}, GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings);
版权声明:本文为weixin_44019016原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。