Json 格式显示public static void Register(HttpConfiguration config) { //////////////设置不以xml格式返回 config.Formatters.Remove(config.Formatters.XmlFormatter); /////////////// config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = RouteParameter.Optional } ); }
json 去掉双引号 JavaScriptSerializer serializer = new JavaScriptSerializer(); //JSON序列化 string result = serializer.Serialize(list); //格式化Json引号"" var respRet = new HttpResponseMessage { Content = new StringContent(result, System.Text.Encoding.UTF8, "application/json") }; return respRet;
原文地址:https://www.cnblogs.com/kunlunmountain/p/9228810.html
时间: 2024-10-14 20:02:45