JSON – How it is changing the Information Landscape?
Before getting into details, Lets check out how a simple JSON content looks like
The example shows the Name, Age and Country date for John, Michael and Jim. If you see its fairly simple, there are keys and there are values. For showing collections we have an array with each value separated by comma.
- A collection of name/value pairs. This is like a Map or associative array where you have values denoted by keys (in our example “Name”, “Age” and “Country” are keys whereas “Jim”, 24, “Australia” are values.
- An ordered list of values. This is like an Array or a List of values, comma separated. In our example we have data of thee people encapsulated in curly braces and separated by comma
Scenarios where JSON can be used
Due it its simplicity, JSON is being used in a number of places. Some scenarios are
Data exchange happens to be one of the most important usage of JSON. Imagine you have two different systems (when I say different it could mean technically different, like a server which has been build on Java and a client which has been written in ASP.NET), Since there cannot be a language dependent thing that could act as their medium, choices are XML or simple Text. Simple text is not formatted and cannot be parsed easily. XML is too complicated and parsing is very expensive. JSON on the other hand falls in between and can be easily parsed.
Now if we do myObj.Name, we can get the value in key Name for the first item. I love how you can write strongly typed code with this ease of use.
Webservices happen to be the best medium when connecting different systems. When Webservices first became popular XML was thought to be the format of data exchange. However now JSON has replaced that. REST Full web services use JSON heavily (giving rise to a very popular term JSON over REST).