ENAUTO – JSON LIVES(!), review of all things JSON (Objects, Strings, Arrays), object example, and awesome website / learning method to EASILY LEARN JSON!


I tried to find a Jason Mask in ASCII but I settled for this image, I think its up there with the elephant with its Trunk stuck to a womans face, pretty awesome stuff 🙂

This was kind of mess to throw together (as you will see) though I believe I got most of the theory and syntax / wording correct, however if nothing else at the bottom of the page is a method to learn JSON for absolutely ANYONE so if nothing else read there!

What is JSON Encoding?

JSON stands for “Java Script Object Notation” and is a subset of JavaScript Syntax, and uses JSON “Objects” to describe sets of data transferred between Servers and Clients.

JSON is largely if not entirely used for Web Service / REST APIs that are Northbound APIs meant to allow Applications to speak to the SDN Controller, while some REST APIs use XML to encode their data, most rely on JSON encoding for their data.

High level Javascript review and an example of JS / JSON encoding

  • Scripting Language, one of the core languages used in building websites as well as HTML and CSS
  • Defines variables, objects, functions, etc
  • Identified in raw HTML with the <script> and </script> modules
  • Adds behaviors and interactivity to websites
  • JavaScript can be disabled, or be the incorrect version to run certain applications
  • JavaScript Objects are containers that encloses one or more “name:value” pairs, which are sometimes called “key-value pair”

One example of this would be:

{[“name” : “Loopy”, “employer”: “Loopedback”, “salary”:10]}

And this would be an example of a module stating my name / employer / salary that I get paid (Loopedback is not known for high wages).

However you can see the logic very plainly with this script, almost in a Q&A format.

This is the JavaScript subset of its language used for JSON encoding, which is much more “human readable” or intuitive than its counterpart XML, which seems to be geared more towards machine reading / processing than for human consumption.

Not the XML is unreadable like Puppet and Chefs Ruby-offshoot coding language, XML is a bit harder to read due to its structure rather than segments or chunks of data, but is still readable if you have an application that you just need to use XML with.

JSON Value Types that represent the data being encoded

Being that JSON is JavaScript “Object Notation” first we’ll look at what these “Objects” are and how exactly we “Notate” them to make up JSON language, which will be listed here:

  • JSON Objects are denoted by being enclosed in {Curly Brackets}
  • Composed of one or more name-value pairs within Curly Brackets
  • Strings must be enclose with double quotations to indicate they are a string, and they will come before the value, for example {“Company”: “Loopedback”} which is a Name-Value Pair although both parts of this are in “String” format
  • We could use String for the first part and an Integer or Floats for example {“Salary”: 10} or even use an Array discussed below (multiple objects separated by commas)
  • Note that adding the Curly brackets on the ends makes these strings actual JSON Objects with single strings inside of them!
  • Arrays (similar to a Python ‘list’) is another String type, where integers are comma separated and are enclosed in square brackets, example {“maxAge”: [2,4,6,8]} and this will also apply to using multiple objects as a “Value” separated by commas which will be demonstrated at the bottom of these bullet points here
  • Multiple Name-Value pairs within an Object are also comma separated
  • Boolean is another option, I would see a usual case use for this as {“present”: true} along with a “Null” Object that would look something like{“route”: null}
  • JSON DOES NOT SUPPORT: Dates, Functions, or Undefined
  • Spaces or Line Breaks don’t matter to JSON encoding!

So lets say I wanted to explain my website in JSON freestyle here with all these values:

{ “website”: [{“name”: “Loopedback”, “author”: “Loopy”, “posts”: 328}]}

So this entire entity is an Object, which has an Array that is shown by the [ ] brackets and comma separated Name-Value pairs, that is made up of multiple name-value objects separated by commas – Hence the new { } to define the Array as a single Value to this objects Name-Value orientation.

The normal colors is the Object as a whole, the slightly noticeable Red Square Brackets indicates an Array of Data as the “Value” field, and then multiple Value fields are entered separated by commas which is the portion highlighted in blue.

One amazing and powerful tool to learn JSON and XML using Cisco IOS Devices!

One really amazing way of seeing how say a Cisco Routers running-config is to do a “show run | format” and the output will be the running-config in XML Format, then you can copy and paste that into this website to convert it to JSON:


So you can start with nothing configured, and slowly add configs and review the code changes to see how the XML and JSON format builds with your running config.

Make up your own questions using lab running-configs to learn JSON!!!

If you have a simple (or complex) lab setup in GNS3 / EVE / wherever, you can pull the running config from a single device using “sh run | format” and getting the JSON output from the above website and pasting it into a text editor or notepad – Then write down some questions based on the Topology!

Which Egress interface will a packet take destined for network x.x.x.x?

Is SSH allowed from x.x.x.x to Interface X/X on this device?

You may rarely be asked to write straight JSON coding for REST APIs, however being able to interpret output may prove critical on an exam or on the job, so I so highly encourage you to even use Packet Tracer to make simple topologies and practice reading JSON output or practice with members of DevNet study group (Hint Hint Reddit)!!!

And that finishes off my first “Intro to Automation” instructor led course

Next up is NETCONF / RESTCONF studies, its late on a Monday so I’m tapping out, until next time!



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s