Construct valid JSON-encoded files

📘CCNP Encore (350-401-ENCORE-v1.1)


What is JSON?

JSON stands for JavaScript Object Notation.

JSON is:

  • A text-based data format
  • Easy for humans to read
  • Easy for machines to parse
  • Widely used in network automation, REST APIs, and controller-based networking

In modern Cisco networks, JSON is commonly used to:

  • Exchange data with REST APIs
  • Send configuration to controllers
  • Receive operational data from devices
  • Work with automation tools like Python scripts, Ansible, and Cisco DNA Center

Why JSON Is Important for CCNP ENCOR

For the ENCOR exam, you must:

  • Understand JSON structure
  • Know JSON rules
  • Be able to build valid JSON files
  • Identify valid vs invalid JSON
  • Understand how JSON is used in network automation

The exam does not test JavaScript, only JSON format and structure.


Basic Structure of a JSON File

A JSON file is made of:

  • Objects
  • Arrays
  • Key–value pairs

JSON Object

A JSON object:

  • Is enclosed in curly braces { }
  • Contains key–value pairs

Example:

{
  "hostname": "Router1"
}

Key–Value Pairs

Key

  • Must be a string
  • Must be enclosed in double quotes

Value

Can be:

  • String
  • Number
  • Boolean
  • Object
  • Array
  • null

Example:

{
  "device": "Switch1",
  "version": 17.6,
  "managed": true
}

Data Types in JSON

1. String

  • Enclosed in double quotes
  • Single quotes are not allowed
"interface": "GigabitEthernet0/1"

2. Number

  • No quotes
  • Can be integer or decimal
"mtu": 1500

3. Boolean

  • Only true or false
  • Lowercase only
"enabled": true

4. null

  • Represents no value
"description": null

5. Object (Nested JSON)

An object inside another object:

{
  "device": {
    "hostname": "Router1",
    "ip": "192.168.1.1"
  }
}

6. Array

  • Enclosed in square brackets [ ]
  • Can contain multiple values
  • Values are separated by commas

Example:

{
  "vlans": [10, 20, 30]
}

Array of objects:

{
  "interfaces": [
    {
      "name": "GigabitEthernet0/0",
      "status": "up"
    },
    {
      "name": "GigabitEthernet0/1",
      "status": "down"
    }
  ]
}

Rules for Valid JSON (VERY IMPORTANT FOR EXAM)

1. Use Double Quotes Only

✅ Correct:

"hostname": "Switch1"

❌ Incorrect:

'hostname': 'Switch1'

2. No Trailing Commas

❌ Incorrect:

{
  "ip": "10.1.1.1",
}

✅ Correct:

{
  "ip": "10.1.1.1"
}

3. Keys Must Be Strings

❌ Incorrect:

{ hostname: "Router1" }

✅ Correct:

{ "hostname": "Router1" }

4. Proper Opening and Closing Brackets

Every { must have a }
Every [ must have a ]


5. Case Sensitivity

JSON is case-sensitive:

"IP" ≠ "ip"

Whitespace Does Not Matter

JSON ignores:

  • Spaces
  • Tabs
  • Line breaks

These are both valid:

{"name":"Router1"}
{
  "name": "Router1"
}

Common JSON Used in IT and Networking

Device Information

{
  "hostname": "CoreSwitch",
  "model": "C9500",
  "os": "IOS-XE",
  "version": "17.9.3"
}

Interface Configuration

{
  "interface": "GigabitEthernet1/0/1",
  "ip_address": "192.168.10.1",
  "subnet_mask": "255.255.255.0",
  "enabled": true
}

Controller or API Response

{
  "status": "success",
  "device_count": 25,
  "timestamp": "2025-12-19T10:30:00"
}

JSON in REST APIs (Exam Focus)

In REST APIs:

  • Requests are often sent in JSON
  • Responses are usually returned in JSON

POST Request Example

{
  "username": "admin",
  "password": "cisco123"
}

Response Example

{
  "token": "ABCD1234",
  "expires_in": 3600
}

JSON vs XML (Quick Comparison for Exam)

FeatureJSONXML
FormatKey–valueTag-based
ReadabilityEasyMore complex
SizeSmallerLarger
Common in APIsYesLess common

ENCOR focuses more on JSON than XML.


Valid vs Invalid JSON Examples

Valid JSON

{
  "router": "R1",
  "interfaces": ["Gig0/0", "Gig0/1"],
  "active": true
}

Invalid JSON

{
  router: "R1",
  "interfaces": ["Gig0/0", "Gig0/1",],
  "active": True
}

Problems:

  • Key not in quotes
  • Trailing comma
  • Boolean must be lowercase

What You Must Remember for the Exam

Key Exam Points

✔ JSON uses key–value pairs
✔ Keys and string values use double quotes
✔ Supports objects and arrays
No trailing commas
Case-sensitive
✔ Commonly used in APIs and automation
✔ Widely used with Cisco controllers and tools


Exam Tip

If the exam asks:

“Which JSON file is valid?”

Check in this order:

  1. Double quotes only?
  2. No trailing commas?
  3. Correct brackets?
  4. Lowercase true / false?
  5. Proper nesting?

Summary

JSON is a critical skill for modern network engineers.
For CCNP ENCOR:

  • You don’t need to write programs
  • You must recognize, read, and construct valid JSON
  • Focus on syntax rules, data types, and structure

Mastering JSON makes automation, APIs, and controller-based networking much easier—and helps you pass the ENCOR exam confidently.


Buy Me a Coffee