#

Sunday, April 12, 2020

JSON Syntax & Scripting Basics

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 ]

No comments:

Post a Comment