Magento 2: Return JSON, XML, HTML & Raw Text Data Response from Controller

This article shows how you can return JSON data, XML data, HTML data, or Raw Text data from any Controller class in Magento 2. Generally, in the Magento2 controller’s execute() function, we see the redirect or forwarding call which redirects to the specified URL page. However, we might sometime need to return the JSON format … Read more

AngularJS: Working with JSON Data & HTTP Service

This article shows an example on how you can fetch JSON data from external file. First, let’s create an example of inline JSON data inside the controller. In the below code, in countryController, we have countries array containing country and capital name. In the HTML view, we have used ng-repeat directive to loop through the … Read more

Python: Read Write JSON

In this article, I will be showing how to read data from a JSON file and write data to a new JSON file using Python programming language. Suppose, I have the following JSON data which is saved in a file named sample-1.json. Download: sample-1.json {"votes": {"funny": 25, "useful": 59, "cool": 29}, "user_id": "1", "name": "User … Read more

PHP: Read Write JSON

JSON stands for JavaScript Object Notation. It is a light-weight text-based open standard designed for human-readable data. It is language-independent, with parsers available for many languages. The JSON format is often used for serializing and transmitting structured data over a network connection. It is used primarily to transmit data between a server and web application, … Read more