#

Tuesday, April 21, 2020

XML (eXtended Markup Language) is a data interchange format just like JSON and YAML which pretty much does the same thing in networking applications. This is the most simplest format of its type and have few rules only. You can see this file type as .xml

HTML (Hypertext Markup Language) and XML are related to each other where HTML is used for the data presentation whereas the main purpose of XML is to store and transfer the data. HTML is a simple, predefined language and XML is a data interchange format.

Information is stored in between tags and they are also called elements. These elements themselves can be enclosed within other elements and can be called child elements and parent elements.

Let's analyze a simple XML script..

As you can see, this script contains information about networking devices.

Tags / Elements can have any name, cannot have spaces.

<networking_devices> is the root tag or parent element of all tags.

Elements on 3rd and 4th lines are child elements of the parent element on 2nd line.


Sunday, April 12, 2020

JSON is a data interchange format which is used to store information which can be used as a replacement for YAML. Basically both of them do the same thing with different syntax. Please refer YAML Syntax & Scripting Basics post to learn about YAML scripting.

JSON stands for Java Script Object Notation and the files can be seen with .json format.

Let's see an example script.























Whole file is enclosed with {} curly brackets. In this example line 1 and line 21.

Router-01 is an object and name , location , model etc are variables and the right side values after : colon are values. Each value ends with a , comma and it is there to separate the values.

Router-01.name is the way to access the value stored in variable name and it will result the answer WAN-RTR-A as a string.

model is an integer data type and OS_version is a floating number data type variable.

true on 7th line is a Boolean answer and the null is equal to no value and they are key words in JSON.

routing_protocols is a list and the list values are starting with [] square brackets.

features is an object which is inside the object Router-01 and it lists blocks of variables which again enclosed by {} curly brackets.

Note:-
Objects start with { and end with }
Commas separate objects, last item of a list does not end with a comma
Double quotes wrap names and strings
Lists start with [ and end with ]

Saturday, April 11, 2020

YAML (Ain't Markup Language), originally named as Yet Another Markup Language is a data interchange format / data serialization language which is used to store information. You may see it in .yaml or .yml format scripts.

YAML can used to store information about different things like objects, variables and lists..

Let's see an example script and identify what information is stored in it.





























The script begins with --- and ends with ...
That is an option to mark the start of the script and the end.

The 1st line Router-01 is an object name. It's an object of  information. It is the parent object of all the information objects under that. Rest of the code which are indented below that are the the information stored in that object in the forms of variables/ lists etc.

As an example the 2nd line name is a child object / key (variable) and is mapped to the value of WAN-RTR-A which are inside a double/single quotes.

This variable can be accessed with objectname.key format code.
As an example Router-01.name will give the value of WAN-RTR-A and Router-01.model will give the value of 2602.

routing_protocols is a list / array. It just lists some values. Note that the list items are starting with a - dash.

interfaces is also a list which is written in another format.

failover will call a null value.

model is an integer while OS_version is a floating value.

Value of serial_number variable will call 23456 only. &id_anchor is used there which we call an "anchor" so that another variable can refer it from somewhere. In this case it is referred from line 30 variable id.

features is a list of objects. There are information about 3 features, SNMP, SSH and IPSec. These 3 are the objects and they are written in 3 different ways which gives the same result.

description variable has a paragraph of information and the key starts with > which means these information will be parsed as a single line. Because of the readability of the code, it is separated by breaking lines.

summary is a variable of information which starts with | and it means the format of the paragraph is parsed just like in the code.

base is a variable list which is anchored and referred by another variable list named caller. << states that the variable along with the value is parsed when it is called.

You can also change the parsing of data types when called rather than importing the original.
As an example model: !!float 2602  will change the data type of integer to a floating number 22.0 when parsing. Also OS_version: !!str 15.4 will change the data type of floating to a string of "15.4" when parsing.

If you want to create another object named Router-02 to store information about another student like this, it should be written with correct indentation. Which means the spacing distance of the line 1 must be equal in the line of next object..

Note:-
Key-value pairs are separated by : (colon)
Lists begin with a – (hyphen)
Indentation is a requirement. You have to use spaces, you can’t use tabs
You can add comments with a #