{"id":343972,"date":"2022-07-13T13:20:38","date_gmt":"2022-07-13T13:20:38","guid":{"rendered":"https:\/\/webkul.com\/blog\/?p=343972"},"modified":"2025-12-11T09:09:53","modified_gmt":"2025-12-11T09:09:53","slug":"how-to-get-response-in-json-xml-html-format-from-controller-in-magento2","status":"publish","type":"post","link":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/","title":{"rendered":"How to get response in Json, Xml, Html format from controller in Magento2"},"content":{"rendered":"\n<p>In this guide, we\u2019ll walk through how to get response in JSON, XML, HTML format from controller in Magento 2 using clean and practical code examples.<\/p>\n\n\n\n<p>We can change the response content type as per the requirement in magento.<br>We assume our module name is\u00a0<strong>Webkul_Extension<\/strong>\u00a0and front name is\u00a0<strong>webext<\/strong>.<br><\/p>\n\n\n\n<p>Step #1 = Get response in json format in magento 2.<br>Path = app\/code\/Webkul\/Extension\/Controller\/Index\/Json.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\Extension\\Controller\\Index;\n\nclass Json extends \\Magento\\Framework\\App\\Action\\Action\n{\n\tprotected $_pageFactory;\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\JsonFactory\n     *\/\n    protected $resultJsonFactory;\n\n\tpublic function __construct(\n\t\t\\Magento\\Framework\\App\\Action\\Context $context,\n\t\t\\Magento\\Framework\\View\\Result\\PageFactory $pageFactory,\n        \\Magento\\Framework\\Controller\\Result\\JsonFactory $resultJsonFactory\n    ) {\n\t\t$this-&gt;resultJsonFactory = $resultJsonFactory;\n\t\treturn parent::__construct($context);\n\t}\n\tpublic function execute()\n\t{\n        $result = $this-&gt;resultJsonFactory-&gt;create();\n\t\t\/\/ Response in json format\n        $data = &#091;\n            &#039;product&#039; =&gt;&#039;Product Data&#039;,\n            &#039;profile&#039; =&gt;&#039;Profile Data&#039;,\n        ];\n        $result-&gt;setData($data);\n        return $result;\n\t}\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"429\" height=\"173\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\" alt=\"Screenshot-from-2022-07-13-12-09-54\" class=\"wp-image-343982\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png 429w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54-300x121.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54-250x101.png 250w\" sizes=\"(max-width: 429px) 100vw, 429px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>Step #2 = Get response in HTML format in magento 2.<br>Path = app\/code\/Webkul\/Extension\/Controller\/Index\/Html.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\Extension\\Controller\\Index;\n\nclass Html extends \\Magento\\Framework\\App\\Action\\Action\n{\n\tprotected $_pageFactory;\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\RawFactory\n     *\/\n    protected $resultRawFactory;\n       \n\tpublic function __construct(\n\t\t\\Magento\\Framework\\App\\Action\\Context $context,\n\t\t\\Magento\\Framework\\View\\Result\\PageFactory $pageFactory,\n        \\Magento\\Framework\\Controller\\Result\\RawFactory $resultRawFactory,\n    ) {\n\t\t$this-&gt;resultRawFactory = $resultRawFactory;\n\t\treturn parent::__construct($context);\n\t}\n\tpublic function execute()\n\t{\n        $result = $this-&gt;resultRawFactory-&gt;create();\n        \/\/ $result-&gt;setHeader(&#039;Content-Type&#039;, &#039;text\/xml&#039;);\n        \/\/ Response in html format\n        $content = &#039;&lt;h1&gt;Webkul product&lt;\/h1&gt;\n                    &lt;p&gt;Webkul product content goes here&lt;\/p&gt;&#039;;\n        $result-&gt;setContents($content);\n\n        return $result;\n\t}\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"313\" height=\"164\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-51.png\" alt=\"Screenshot-from-2022-07-13-12-13-51\" class=\"wp-image-343984\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-51.png 313w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-51-300x157.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-51-250x131.png 250w\" sizes=\"(max-width: 313px) 100vw, 313px\" loading=\"lazy\" \/><\/figure>\n\n\n\n<p>#2 = Get response in XML format in magento 2.<br>Path = app\/code\/Webkul\/Extension\/Controller\/Index\/Xml.php<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\">&lt;?php\nnamespace Webkul\\Extension\\Controller\\Index;\n\nclass Xml extends \\Magento\\Framework\\App\\Action\\Action\n{\n\tprotected $_pageFactory;\n    \/**\n     * @var \\Magento\\Framework\\Controller\\Result\\RawFactory\n     *\/\n    protected $resultRawFactory;\n       \n\tpublic function __construct(\n\t\t\\Magento\\Framework\\App\\Action\\Context $context,\n\t\t\\Magento\\Framework\\View\\Result\\PageFactory $pageFactory,\n        \\Magento\\Framework\\Controller\\Result\\RawFactory $resultRawFactory,\n    ) {\n\t\t$this-&gt;resultRawFactory = $resultRawFactory;\n\t\treturn parent::__construct($context);\n\t}\n\tpublic function execute()\n\t{\n        $result = $this-&gt;resultRawFactory-&gt;create();\n        \/\/ Response in xml format\n        $content = &#039;&lt;product&gt;\n                        &lt;productData&gt;Webkul product&lt;\/productData&gt;\n                        &lt;profileData&gt;Webkul&lt;\/profileData&gt;\n                    &lt;\/product&gt;&#039;;\n        $result-&gt;setHeader(&#039;Content-Type&#039;, &#039;text\/xml&#039;);\n        $result-&gt;setContents($content);\n\n        return $result;\n\t}\n}<\/pre>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"759\" height=\"169\" src=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-29.png\" alt=\"Screenshot-from-2022-07-13-12-13-29\" class=\"wp-image-343985\" srcset=\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-29.png 759w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-29-300x67.png 300w, https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-13-29-250x56.png 250w\" sizes=\"(max-width: 759px) 100vw, 759px\" loading=\"lazy\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In this guide, we\u2019ll walk through how to get response in JSON, XML, HTML format from controller in Magento 2 using clean and practical code examples. We can change the response content type as per the requirement in magento.We assume our module name is\u00a0Webkul_Extension\u00a0and front name is\u00a0webext. Step #1 = Get response in json format <a href=\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\">[&#8230;]<\/a><\/p>\n","protected":false},"author":440,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-343972","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Get response in Json, Xml, Html format from controller in Magento2<\/title>\n<meta name=\"description\" content=\"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Get response in Json, Xml, Html format from controller in Magento2\" \/>\n<meta property=\"og:description\" content=\"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\" \/>\n<meta property=\"og:site_name\" content=\"Webkul Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webkul\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-07-13T13:20:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-12-11T09:09:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\" \/>\n<meta name=\"author\" content=\"Amir Khan\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webkul\" \/>\n<meta name=\"twitter:site\" content=\"@webkul\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Amir Khan\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\"},\"author\":{\"name\":\"Amir Khan\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a\"},\"headline\":\"How to get response in Json, Xml, Html format from controller in Magento2\",\"datePublished\":\"2022-07-13T13:20:38+00:00\",\"dateModified\":\"2025-12-11T09:09:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\"},\"wordCount\":115,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\",\"url\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\",\"name\":\"Get response in Json, Xml, Html format from controller in Magento2\",\"isPartOf\":{\"@id\":\"https:\/\/webkul.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\",\"datePublished\":\"2022-07-13T13:20:38+00:00\",\"dateModified\":\"2025-12-11T09:09:53+00:00\",\"description\":\"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.\",\"breadcrumb\":{\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png\",\"width\":429,\"height\":173,\"caption\":\"Screenshot-from-2022-07-13-12-09-54\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/webkul.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to get response in Json, Xml, Html format from controller in Magento2\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/webkul.com\/blog\/#website\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"name\":\"Webkul Blog\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/webkul.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/webkul.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/webkul.com\/blog\/#organization\",\"name\":\"WebKul Software Private Limited\",\"url\":\"https:\/\/webkul.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"contentUrl\":\"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png\",\"width\":380,\"height\":380,\"caption\":\"WebKul Software Private Limited\"},\"image\":{\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webkul\/\",\"https:\/\/x.com\/webkul\",\"https:\/\/www.instagram.com\/webkul\/\",\"https:\/\/www.linkedin.com\/company\/webkul\",\"https:\/\/www.youtube.com\/user\/webkul\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a\",\"name\":\"Amir Khan\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g\",\"caption\":\"Amir Khan\"},\"url\":\"https:\/\/webkul.com\/blog\/author\/amir-khan754\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Get response in Json, Xml, Html format from controller in Magento2","description":"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/","og_locale":"en_US","og_type":"article","og_title":"Get response in Json, Xml, Html format from controller in Magento2","og_description":"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.","og_url":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/","og_site_name":"Webkul Blog","article_publisher":"https:\/\/www.facebook.com\/webkul\/","article_published_time":"2022-07-13T13:20:38+00:00","article_modified_time":"2025-12-11T09:09:53+00:00","og_image":[{"url":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png","type":"","width":"","height":""}],"author":"Amir Khan","twitter_card":"summary_large_image","twitter_creator":"@webkul","twitter_site":"@webkul","twitter_misc":{"Written by":"Amir Khan","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#article","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/"},"author":{"name":"Amir Khan","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a"},"headline":"How to get response in Json, Xml, Html format from controller in Magento2","datePublished":"2022-07-13T13:20:38+00:00","dateModified":"2025-12-11T09:09:53+00:00","mainEntityOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/"},"wordCount":115,"commentCount":0,"publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png","inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/","url":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/","name":"Get response in Json, Xml, Html format from controller in Magento2","isPartOf":{"@id":"https:\/\/webkul.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage"},"image":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage"},"thumbnailUrl":"https:\/\/webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png","datePublished":"2022-07-13T13:20:38+00:00","dateModified":"2025-12-11T09:09:53+00:00","description":"How to get response in Json, Xml, Html format from controller in Magento 2. Return in Json, Xml, Html format from controller in Magento2.","breadcrumb":{"@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#primaryimage","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2022\/07\/Screenshot-from-2022-07-13-12-09-54.png","width":429,"height":173,"caption":"Screenshot-from-2022-07-13-12-09-54"},{"@type":"BreadcrumbList","@id":"https:\/\/webkul.com\/blog\/how-to-get-response-in-json-xml-html-format-from-controller-in-magento2\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/webkul.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to get response in Json, Xml, Html format from controller in Magento2"}]},{"@type":"WebSite","@id":"https:\/\/webkul.com\/blog\/#website","url":"https:\/\/webkul.com\/blog\/","name":"Webkul Blog","description":"","publisher":{"@id":"https:\/\/webkul.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/webkul.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/webkul.com\/blog\/#organization","name":"WebKul Software Private Limited","url":"https:\/\/webkul.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","contentUrl":"https:\/\/cdnblog.webkul.com\/blog\/wp-content\/uploads\/2021\/08\/webkul-logo-accent-sq.png","width":380,"height":380,"caption":"WebKul Software Private Limited"},"image":{"@id":"https:\/\/webkul.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webkul\/","https:\/\/x.com\/webkul","https:\/\/www.instagram.com\/webkul\/","https:\/\/www.linkedin.com\/company\/webkul","https:\/\/www.youtube.com\/user\/webkul\/"]},{"@type":"Person","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/f2493d3639b5e8c05ae4e9af5f71063a","name":"Amir Khan","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/webkul.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/da678755fca2993231591a761683dc95fcf81f335982ea5c1b38e9ccc1c6bc0c?s=96&d=https%3A%2F%2Fcdnblog.webkul.com%2Fblog%2Fwp-content%2Fuploads%2F2019%2F10%2Fmike.png&r=g","caption":"Amir Khan"},"url":"https:\/\/webkul.com\/blog\/author\/amir-khan754\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/343972","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/users\/440"}],"replies":[{"embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/comments?post=343972"}],"version-history":[{"count":5,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/343972\/revisions"}],"predecessor-version":[{"id":516488,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/posts\/343972\/revisions\/516488"}],"wp:attachment":[{"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/media?parent=343972"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/categories?post=343972"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/webkul.com\/blog\/wp-json\/wp\/v2\/tags?post=343972"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}