{"id":174,"date":"2017-04-17T12:40:13","date_gmt":"2017-04-17T12:40:13","guid":{"rendered":"http:\/\/windows.emacslisp.com\/?p=174"},"modified":"2017-04-17T12:48:48","modified_gmt":"2017-04-17T12:48:48","slug":"webapi-remove-web-api-json-string-only","status":"publish","type":"post","link":"http:\/\/windows.emacslisp.com\/index.php\/2017\/04\/17\/webapi-remove-web-api-json-string-only\/","title":{"rendered":"webapi &#8211; remove web api json string only"},"content":{"rendered":"<p>by default web api return is xml only. even return json string, but it is still embedded inside an xml file.<\/p>\n<p>for example:<\/p>\n<pre lang=\"xml\" line=\"1\" escaped=\"true\"> \r\n<string xmlns=\"http:\/\/schemas.microsoft.com\/2003\/10\/Serialization\/\">\r\n[{\"Id\":1,\"Name\":\"Glenn Block\"},{\"Id\":2,\"Name\":\"Dan Roth\"}]\r\n<\/string>\r\n<\/pre>\n<p>in WebApiConfig.cs: <\/p>\n<pre lang=\"csharp\" line=\"1\">\r\n  config.Formatters.Remove(config.Formatters.XmlFormatter);\r\n <\/pre>\n<p>then it will be json string only.<\/p>\n<p>Another sub topic is json object in C#.<\/p>\n<p>add reference in visual studio that json serialization.<br \/>\nusing System.Web.Script.Serialization;<\/p>\n<p><strong> System.Web.Script.Serialization is inside System.Web.Extensions.<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>by default web api return is xml only. even return json string, but it is still embedded inside an xml file. for example: [{&#8220;Id&#8221;:1,&#8221;Name&#8221;:&#8221;Glenn Block&#8221;},{&#8220;Id&#8221;:2,&#8221;Name&#8221;:&#8221;Dan Roth&#8221;}] in WebApiConfig.cs: config.Formatters.Remove(config.Formatters.XmlFormatter); then it will be json string only. Another sub topic is &hellip; <a href=\"http:\/\/windows.emacslisp.com\/index.php\/2017\/04\/17\/webapi-remove-web-api-json-string-only\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/174"}],"collection":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/comments?post=174"}],"version-history":[{"count":3,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/174\/revisions"}],"predecessor-version":[{"id":177,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/posts\/174\/revisions\/177"}],"wp:attachment":[{"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/media?parent=174"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/categories?post=174"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/windows.emacslisp.com\/index.php\/wp-json\/wp\/v2\/tags?post=174"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}