Network Kings

What is JSON and How to Interpret JSON Encoded Data?

what is json?

Welcome back to the CCNA series where we cover all the important topics that are asked in the Cisco Certified Network Associate (CCNA 200-301) exam. 

In the previous blog of our CCNA 200-301 series , we talked about the containers in cloud computing. I recommend you go through it before you jump to this blog. 

It is time to move further in our free CCNA series to the next concepts. You are going to learn about JSON which is also known as Data Serialization Language or Data Serialization Format. This language also allows us to format or structure data in a standardized way so that it can also be used to communicate between applications. Other data serialization languages include XML and YAML.

You will also learn how to interpret JSON-encoded data. In this blog, we will cover the following important concepts:

  • Data serialization: What is it and why do we need it?
  • JSON (JavaScript Object Notation): How to interpret JSON basic JSON-encoded data?

Without any further ado, let’s begin learning!

What is Data Serialization?

Data serialization refers to the process of converting data into a standardized format/structure that can be stored in a file or transmitted over a network and rebuilt later (i.e., by a different application). This standardized format makes sure that all the data sources have the same format and labels.

Why is it useful?

It allows the data to be communicated between applications in such a way that it could be understood by both applications. For example, if one application is written in PHP, and the other is written in Python, both languages store data differently. Therefore, they need a standard format to send data to each other.

The data serialization languages such as JSON allow us to represent variables with text. Firstly, you need to understand what is a variable. 

Variables are containers that store values. These could be the values of “IP-address”, “status”, “netmask”, etc.  For example, 

“Status”: up

Here, “status” is variable, and “up” is value. 

How Data is Exchanged Without Data Serialization?

Without the use of any data serialization language/format, if an app is trying to get information from an SDN controller, it sends a GET message to the controller. The server, the controller, sends those variables directly to the client without converting them to a standard format like JSON.

This way, the client doesn’t understand the received data. This is because the app and the controller are written in different languages and they store data differently. This is why they can’t communicate directly.

How Does Data Serialization by JSON Works?

Data serialization is a process that is often supported by many different languages such as Java, PHP, etc. it breaks the object (data) into different formats so that it could be understood by another application. One of the most commonly used data serialization language is JSON. 

It often helps in making communication possible between a client and server. Since both of them understand different languages, JSON acts as a medium.

Whenever a client wants some information from the server, it sends a GET request to the server. The server in turn, sends it back to an API which converts internal variables into JSON format.

These JSON-formatted variables are sent to the client which is then understood by it. As required, the client can convert this data into its internal variables.

Therefore, JSON helps in converting the data into a standardized format that could be understood by any application.

What is meant by JSON?

JSON (JavaScript Object Notation) is a human-readable text language that represents the Java arrays, lists, data, etc. It is also a standard to convert internal variables into a standardized format. It can send data to any client present over the network and it can also save files.

It uses human-friendly text to store and transmit data objects. Therefore, JSON is a data standardization language that could be understood by both humans and machines.

The following are some of the key features of JSON:

  • It is standardized according to the RFC 8259.
  • JSON has been derived from JavaScript. However, it is language-independent and many modern programming languages can create and read JSON data.
  • REST APIs make use of JSON. (We will learn about REST APIs in the upcoming blogs.)
  • Spaces and linebreaks do not matter to JSON.
  • There are four primitive data types in JSON:
    • String: It is a text value. 
    • Number: It is a numeric value.
    • Boolean: it is a data type that has only two possible values.
    • Null: It represents the absence of any object value.
  • There are two structured data types in JSON:
    • Object: It is an unordered list of key-value pairs, i.e., variables.
    • Array: It is a series of values separated by commas. It is NOT key-value pairs.

Let us now cover the structured data types in detail!

What are JSON Structured Data Types?

It is very important to understand the structured data types of JSON to interpret the JSON formatted files. The best part about JSON is that it can be read by humans as well as machines.

As discussed earlier, there are two types of structured data in JSON. Let’s cover them one by one to understand JSON scripts in a better way.

Object:

  • An object is referred to as a jumbled list of key-value pairs (variables) that do not have any order.
  • We use curly brackets ({}) to represent objects.
  • The key is of a string primitive data type.
  • The value can contain any valid JSON data type such as string, numeric, boolean, null, object, or array.
  • A colon (:) is used to separate the key from the value.
  • In case, there are multiple key-value pairs, each pair is separated by a comma.

Example:

{

  “Interface” : “GigabitEthernet1/1”,

  “Is_up” : true,

   “Ipaddress” : “176.134.1.2”,

   “Netmask” : “255.255.255.0”,

   “Speed” : 1000

 }

Note: objects within objects are called ‘nested objects’.

Array:

  • It is a series of ‘vales’ that are separated by commas.
  • It is NOT a key-value pair.
  • The values do not have to be of the same data type.

Example:

“Interfaces” : [

“GigabitEthernet1/1”,

“GigabitEthernet1/2”,

“GigabitEthernet1/3”

],

“random _values” : [

“Hello”,

  57

]

}

You can see that the data type of “interfaces” is different than that of the “random_values”.

I recommend you practice some questions on the Internet to interpret the JSON data. Just looking at these examples won’t help you in understanding the concept easily. 

Conclusion:

In this guide, we have learned about data serialization languages such as JSON. It is critical to understand this concept if you are preparing to take the CCNA interviews and the CCNA 200-301 exam.

The second most important thing is to learn how to interpret the JSON formats. I recommend you practice more questions. 

Happy learning!

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.