What is JSON?

At some point in history, XML was the most popular choice for data exchange. However, after the rise of web applications and JavaScript. JSON was developed and became the main choice for data exchange.

JSON (JavaScript Object Notation) is a minimal, human-readable format for structuring data. It is used primarily to transmit data between a server and web application, as an alternative to XML. 

JSON has several advantages:

  • It is very compact 
  • It is easily readable for applications and people
  • It is easily mapped into most programming languages' data structures
  • All programming languages have libraries that can read and wire JSON
  • It is just plain text, thus it is easy to send and receive over the network and is language independent


Nowadays, both JSON and XML are widely used. Let’s have a look at the differences between the two:

JSON has a more compact style as compared to XML. XML is less readable compared to JSON and becomes hard to manage in large files.
JSON supports arrays. XML doesn't support arrays.
JSON is more human-readable XML is less human-readable.
JSON supports only text and number data types XML support many data types including images, graphs, etc.

Let's look at the following example to understand why JSON is more human-readable than XML:

XML Example:


JSON Example:

{"name":"Gig0/0", "add":""},
{"name":"Gig0/1", "add":""},
{"name":"Gig0/2", "add":""}

What is JSON used for?

JSON is most widely used for sending and receiving data between web applications. Very common day-to-day usage of JSON is when a browser exchange data with a web server using a technology called AJAX

In Networking, most platforms that have a programming interface API, accept and return HTTP messages that contain JavaScript Object Notation (JSON). Payloads to and from the API interface can be encapsulated through either XML or JSON encoding.