Introduction

The biggest challenge that programmers/developers/architects were facing for quite some time was how to transfer data from one system to another without having to worry about hardware or software requirements. Over this period we have seen many technologies attempting to make this requirement as simple as possible and finally now we have achieved it with the help of JSON.
JSON is an acronym for JavaScript Object Notation. Douglas Crockford originally specified the JSON format in the early 2000s. The features of JSON are as follows:
  1. JSON data is much easier to read by humans in comparison with that of XML which is also used to transfer data from one system to another.
  2. It is a lightweight data-interchange format.
  3. It follows Open Standard Format to transmit data objects that store information in “Key-Value Pair” pattern.
  4. It is a language-independent data format.
  5. JSON can be mapped more easily to object oriented systems.
  6. Files that contain JSON based data have a “.json” extension which can be read by any programming languages.
Typically a JSON looks like the following:
Example 1
  1. {
  2. “Name”:”Jojo”,
  3. “Age”: 23
  4. }
Explanation
The “Name” is the key, “Jojo” is the key’s value. Likewise, “Age” is the key, 23 is the key’s value. If you have noticed for the value 23 there are no double quotes, this proves one more point that JSON supports multiple data types, one of them is a number. Other data types that are supported by JSON apart from Number and String are:
The above example contains details for only one object. If we plan to have an array of objects, then the storage will look like this:
Example 2
  1. {
  2. “Employees”:[
  3. {“Name”:”PopatLal”, “Age”:25},
  4. {“Name”:”Santa Singh”, “Age”:27},
  5. {“Name”:”Banta Singh”, “Age”:28},
  6. {“Name”:”SohanLal”, “Age”:25},
  7. ]
  8. }
In example 2, we have an array of objects called “Employees” containing two components “Name” and “Age”.
Now, the bigger question that comes to our notice is how to get JSON information displayed on a web page using ASP.NET MVC 4. Let us take a step by step approach to see how to work with the same.

Summary

The above example is only to demonstrate how to use JSON in MVC. I hope this article was helpful. Please feel free to share your thoughts/opinion/feedback regarding the same.