In this section we will talk about interpreting the Jason encoded data
javascript object and notation.
Jason attempts to strike a balance between human and mission readability.
Armed with a fear Jason rules most humans can read Jason data moved past simply guessing at what it
means and confidently interpret the data structures defined by the Jason data.
At the same time Jason data makes it easy for programs to convert Jason text into variables making it
very useful for data exchange between applications using API ice you can find the details of Jason in
our FC 8 2 5 9 and in a number of sites found with the Internet searches including the w w w that Jason
that arc saw.
Let's start with the interpreting to Jason as the data flows back and forth between our application
and the network controller.
That data is commonly written in Jason data format.
You can't think of that skill and that the task with two major branches first even ignoring the syntax
and spatial characters anyone who knows the topic can probably make an intelligent guesses about the
meaning of many of the key Valley pairs for example without knowing anything about Jason's syntax.
You could probably do to mine from your prior knowledge of Cisco or others and switches that the Jason
on the screen that lists to the wise maybe they are just names and a list of interfaces on each device.
You can see in here this is Jason.
Yep but we have our one.
Probably.
That's the host name are two.
That's also the house name and the interfaces of the rather one and these are the interfaces of the
rather two right.
Okay.
Honestly you probably already know everything needed to do this kind of intelligent guessing.
However to perform the second type of task where you analyze the adjacent data to find the data structures
including objects lists and key value pairs you need to know a bit more about Jason's syntax.
So let's go ahead with the key value pairs in Jason's syntax guys.
Each and every column identifies one key value pair with the key before the column and the value after
the column so you can see in here we have one true and three key value pairs.
These are the keys and these are the values.
So first best is the key and messy is the value.
Second best is the key run out low is the value.
Third best is the key and Pella is the value.
Okay let's go ahead with the key key is the text inside.
Double quotes before the column.
Use that as the name that area for instance value.
Okay.
We have already talked about this one that should be in.
Yes key should be inside the double quotes and this is our key and you can see it's inside the double
codes and that is before the double column you can see in here.
So inside the double quotes and before the Colum.
Okay so let's go ahead with the value volley is the item after the column that represents the value
of the key which can be a volley can be and taxed guys that should be listed in double quotes like in
here and volley also can be numeric.
If our volley is numeric that is listed without chords that can be an array and object and they are
as some special values then we will talk about more details on our later sections okay on Jason's syntax
when we need to list multiple key value pairs we need to separate the pairs with a comma and NE as you
can see in here the first comma and the second comma but whereas the third comma we don't use the comma
at the end of the last key value pair okay.
Let's go ahead with some more information we have objects and the array terms object is a series of
key value pairs and close to in an matched pair of curly brackets here is the thing that we need to
care about.
Objects should be inside the color brackets guys with an opening left curly bracket and it's matching
right color bracket when it comes to array array is as series of values not key value pairs.
Okay.
Pay attention this one and enclose the in a matched pair of square brackets.
This time with an opening left screen bracket and its matching right square bracket.
So what about the key value pairs inside the objects.
All key value pairs inside an object conform to the earlier rules for the key value pairs.
We talked already and all values inside inside the arrays conform to the earlier rules for formatting
values.
For example double quotes around tags no quotes around the numbers are okay below the screen shows a
single array in Jason format.
In here you can see a single array in Jason format.
Notice the Jason data begins with
two square brackets and then lists three text values in here they are messy Ronaldo and d blah and the
values could have been a mix of values and it ends with another square bracket
while example on previous slide shows only the array itself Jason arrays can be used as a value in any
key value pair figure on the screen does just that and shown in a graphic to elo is here highlighting
of the arrays and the objects.
The Jason text in the figure includes two arrays as values and a these values each from just after column
indicating they are values really.
So here is the first Jason array.
So here it is.
Jason array with
please pay attention to start and finish at the first Jason array.
And this is the first for favorite players and they are messy Ronaldo and Bella.
And this is the second Jason array and it's the favorite teams and they are Barcelona U.N. those and
the document.
So now let's think about the entire structure of the Jason data.
In previous slide it has a matched pair of Charlie brackets to begin and end the text encapsulating
one object that object contains two columns.
So there are two key value pairs inside the object.
When you think about the broader structure as depicted in the figure on the screen you can see now this
Jason File has one Jason object itself with two key value pairs.
Please note that this figure does not show the correct Jason's syntax for the lists.
It instead is intended to make sure used to see the structure of the one object and its two key value
pairs to drive home the idea of how to find Jason objects.
You can consider the examples shown in this slide.
This figure shows the correct Jason's syntax guys and it has the following.
There is one object for the entire set because it begins and ends with curly braces.
You can see it in here
then the outer object has two keys and the first key is when those favorites and the second key is the
interface config.
The value of each key value pair is another object.
So each with curly braces and you can see them here here and here and also we have three key value pairs.
Key value pair.
1 2 3 key value pair 1 2 3 OK.
The Jason example in this slide shows how Jason can list objects and arrays.
That is Jason puts one object or array inside another.
Much of the Jason output you will see as you learn more and more about network automation will include
Jason data with nested arrays and objects okay.
So far all the Jason examples show lots of empty space.
Jason allows for white space or not depending on your needs for humans.
Reading Jason can be a lot easier with the text organized with space and light for instance having the
match to opening and closing brackets sit at the same left offset makes it much easier to find which
brackets go with which when stored in a file or sent in a network.
Jason does not use whitespace For instance earlier in the section figure on a bow of the screenshot
one.
Jason object with three key value pairs with what space taking five lines however stored in a file or
send over and network.
The Jason will look like as the low of the screen.
Most of the tools you might use when working with Jason will let you toggle from our printed format
which is good for humans to air rare round format which is good for computers.
You might see the printed version literally called pretty or a bit of white or spaced while the version
with no extra whitespace might be called meaning fight or ROF.