问题
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)/"
}
回答1:
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.
来源:https://stackoverflow.com/questions/13859321/mvc4-json-net-oob