MVC4 JSON.Net oob [英] MVC4 JSON.Net oob
问题描述
我已经阅读了有关MVC 4对JSON.NET的开箱即用支持的一些相互矛盾的信息
我收集到MVC现在默认使用JSON.NET对JSON进行序列化,但是我的JSON输出中仍然有讲故事的MS日期格式.
是否仍有任何引导过程需要完成?
示例操作:
//
// GET: /Test/
[HttpGet]
public JsonResult Test()
{
return Json(new {date = DateTime.Now}, JsonRequestBehavior.AllowGet);
}
导致:
{
"date": "/Date(1355399663508)/"
}
默认情况下,它仅将Json.net用于asp.net Web api.
按照发行说明 Json.NET::我们现在使用并支持流行的Json.NET序列化器来处理JSON数据. Json.NET是ASP.NET Web API使用的默认JSON序列化程序,它包括对数据协定,匿名类型,动态类型,日期,TimeSpans,对象引用保留,缩进,驼峰式大小写以及许多其他有用的序列化功能的支持. >
I have read a few pieces of conflicting information regarding MVC 4's out-of-the-box support for JSON.NET
I gathered that MVC is serializing JSON by default using JSON.NET now, however I still have the tell-tale MS date format in my JSON output.
Is there any bootstrapping that still needs to be done?
Example action:
//
// GET: /Test/
[HttpGet]
public JsonResult Test()
{
return Json(new {date = DateTime.Now}, JsonRequestBehavior.AllowGet);
}
results in:
{
"date": "/Date(1355399663508)/"
}
It is using Json.net by default for asp.net web api only.
As per release notes Json.NET: We now use and support the popular Json.NET serializer for handling of JSON data. Json.NET is the default JSON serializer used by ASP.NET Web API and it includes support for data contracts, anonymous types, dynamic types, Dates, TimeSpans, object reference preservation, indenting, camel casing and many other useful serialization features.
这篇关于MVC4 JSON.Net oob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!