8

Introduction to JSON for Network Engineers

 3 years ago
source link: https://rowelldionicio.com/intro-to-json-for-devnet/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Intro to JSON for DevNet

October 25, 2019 By Rowell Leave a Comment

In continuation with the DevNet Associate Challenge, I look at the JSON structured data format. It’s heavily used with Cisco documentation and training. If you’re studying for the Cisco DevNet Associate certification, it will be critical to understand JSON and how it will be used with scripting and APIs.

JSON stands for JavaScript Object Notation. It is a syntax for storing and exchanging data, just like XML and YAML.

When we query a device through a script or software application, we can receive that data in JSON format.

The data being transferred can be used for machine-to-machine interaction. It’s human-readable as well. While we may be used to CLI output, as network engineers, it may not be very useful for machines. Therefore, we have a data structure being used such as JSON.

It appears that Cisco may be settling on JSON as the format to use with their APIs. It may be the desired format for other technologies as well.

Using the Meraki sandbox as an example, we make a request and we receive a response in JSON format below (truncated):

[
    {
        "id": "578149602163689099",
        "name": "Test Org 1551210428",
        "url": "https://n27.meraki.com/o/X7M2PbB/manage/organization/overview"
    },
    {
        "id": "578149602163689479",
        "name": "Your org",
        "url": "https://n27.meraki.com/o/wwBiUbB/manage/organization/overview"
    },
    {
        "id": "549236",
        "name": "DevNet Sandbox",
        "url": "https://n149.meraki.com/o/-t35Mb/manage/organization/overview"
    }
]

In it’s simplest form, JSON consists of key-value pairs. The response above is a request for all organizations my account has access to. What we see is the output in a JSON array format which includes various organizations in their own JSON object.

The entire output is the Organizations array. Within that array are objects such as:

{
        "id": "549236",
        "name": "DevNet Sandbox",
        "url": "https://n149.meraki.com/o/-t35Mb/manage/organization/overview"
    }

The key is identified on the left of the colon and the right side is the value. The syntax is simple:

”key”: “value”

What we do not see in JSON structured data is the support for comments. As I’ve pointed out with XML and YAML, there is the capability to add comments with a #.

When working with networking equipment, I personally find JSON to be easier to parse with the eyes.

JSON | XML | YAML

Which format do you prefer to use? Comment down below👇

Filed Under: Coding, DevNet Associate Tagged With: 200-901, devnet associate


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK