Data Serialization Languages: JSON, YAML, XML

json-versus-yaml-versus-xml

Why We Use Data Serialization Languages?

Applications use different programming languages. They store variables used in these programs differently. Because all the programming languages use different architecture. For example, C++ uses a style, Java uses another and Python uses a different one. All these programs’ store mechanism is different. There is no standard between them. During REST API operation, if one side REST Client uses different program and the other end REST Server uses the other one, they can not communicate without a third interpreter. Here, Data Serialization Languages are used. By using this language, both end become similar and they can understand eachother. With Data Serialization Languages, in other words, applications gain a standard method for their different variable mechanisms. One of the most popular one used in Network Automation is JSON (JavaScript Object Notation). Here, we will learn JSON, YAML and XML.

 

So, how is this Data Serialization Language, JSON work between REST Client and REST Server? Let’s check this mechanism step by step

data-serialization-languages-and-json

As you can see above, here JSON plays an interpreter role. The five steps process is like below:

  1. REST Server sends the data to REST API with its original structure. Here, we are using Y Programming language. So, this format is Y Programming languages’s format.
  1. REST API converts Y format to JSON Format.
  1. The message is sent from REST Server to REST Client in JSON Format. The data travel in JSON format.
  1. At the other end, REST Client receives data in JSON Format. Data in JSON Format is converted to X format via JSON Converter.
  1. Data is sent to the applciation with X Format. And X Programming Language can use this data with its structure.

 

Data Serialization Languages

Data Serialization Languages are very important for Network Automation. By using these standards as an interpreter, different applications can communicate eachother. There are differetn types of Data Serialization Languages. The most popular one is JSON (JavaScript Object Notation) for Network Automation. But beside JSON, there are two more languages used for this purposes. So, what are these three Data Serialization Languages? These are:

 

  • JSON (JavaScript Object Notation)
  • XML (eXtensible Markup Language)
  • YAML (YAML Ain’t Markup Language)

json-versus-xml-versus-yaml

 JSON (JavaScript Object Notation) is one of the most popular data modeling language used in Network Automation. Espacially for your network operations and Cisco Certification Studies, this model is important. JSON is a Human-readable language that one can easily understand what it says.

JSON (JavaScript Object Notation) was developed at 2002. Its structure is Map structure and it is a fast data serialization language.

You can find JSON format examples below:

 

{

    Heros: [

        {

        name: Aragorn,

        race: Human,

        role: King

        }

      ]

}

 

Or

 

{

    Routers: [

        {

        hostname: Backbone-1,

        model: CRS-X,

        role: Core

        }

      ]

}

 

 

XML (eXtensible Markup Language) has originally developed for dynamic web pages. With this language, web pages that has dynamic content can be updated easily. But its properties make it also a good data serialization languge for today’s World. It is a little difficult to read XML file but not too much. As in HTML, beginnign and ending tags are used in XML.

XML (eXtensible Markup Language) was developed at 1996. Its structure is Tree structure and it is slow data serialization language, if we compare with JSON.

 

You can find XML format examples below:

 

<Heros>

      <Hero>

            <name>Aragorn</name>

            <race>Human</race>

            <role>King</role>

      </Hero>

</Heros>

 

Or

 

<Routers>

      <Router>

            <hostname>Backbone-1</hostname>

            <model>CRS-X</model>

            <role>Core</role>

      </Router>

</Routers>

 

 

YAML (YAML Ain’t Markup Language) is a data serialization language that has a very funny recursive name. As its name imlies, it isnot a markup language like XML. Instead, it is a data serialiaztion language. If we compare with XML and JSON, YAML is more easy and user friendly. You can easily reas a YAML file.

 

YAML (YAML Ain’t Markup Language) was developed at 2006. Its structure is Map structure and it is a fast data serialization language.

 

You can find YAML format examples below:

 

Heros:

     name: Aragorn

      race: Human

      role: King

 

Or

 

Routers:

      hostname: Backbone-1

      model: CRS-X

      role: Core

 

JSON, YAML and XML Comparison

You can find a comparison table of JSON, YAML and XML below.

json-versus-yaml-versus-xml

 

 

 

Back to: CCNA 200-301 > Automation and Programmability

Leave a Reply

Your email address will not be published. Required fields are marked *

CCNA 200-301

Collapse
Expand