📘CCNA 200-301 v1.1
6.7 Recognize components of JSON-encoded data
JSON Overview
- JSON stands for JavaScript Object Notation.
- It is a lightweight data format used to store and exchange data between devices, applications, and networks.
- In networking, JSON is commonly used in:
- APIs (like REST APIs)
- Network automation tools (like Ansible, Python scripts)
- Controller-based systems (like SDN controllers)
Think of it as a standard way to structure data so devices and software can understand it.
JSON Components
JSON data is made up of basic components:
1. Objects
- Represent a collection of key-value pairs.
- Written inside curly braces
{}. - Key is like the name of the data, and value is the data itself.
- Example (network device info):
{
"hostname": "Switch1",
"ip_address": "192.168.1.10",
"status": "active"
}
Here:
hostname= key,"Switch1"= valueip_address= key,"192.168.1.10"= valuestatus= key,"active"= value
2. Arrays
- Represent lists of items, written inside square brackets
[]. - Can contain objects, strings, numbers, or even other arrays.
- Example (list of interfaces on a device):
{
"interfaces": ["Gig0/1", "Gig0/2", "Gig0/3"]
}
Here:
interfacesis the key- The value is an array of three strings representing interface names.
3. Values
- Can be different types:
- String – Text enclosed in double quotes. Example:
"active" - Number – Numeric values. Example:
100or3.14 - Boolean – True or False. Example:
trueorfalse - Null – Empty or no value. Example:
null - Object – Another collection of key-value pairs
{} - Array – A list of values
[]
- String – Text enclosed in double quotes. Example:
Example combining values:
{
"hostname": "Router1",
"interfaces": ["Gig0/0", "Gig0/1"],
"vlan_count": 5,
"enabled": true,
"description": null
}
4. Key Rules
- Keys must be strings in double quotes.
- Each key must be unique within an object.
- Key-value pairs are separated by a colon
:. - Multiple pairs are separated by commas
,.
Example of multiple key-value pairs:
{
"hostname": "Switch2",
"ip_address": "10.0.0.1",
"status": "inactive"
}
5. Nested Objects
- JSON objects can be inside other objects to represent structured data.
- Example in networking: device with interfaces and VLANs
{
"device": "Switch1",
"interfaces": {
"Gig0/1": {"status": "up", "vlan": 10},
"Gig0/2": {"status": "down", "vlan": 20}
}
}
Here:
interfacesis an object inside the main object- Each interface has its own status and VLAN as key-value pairs
Why JSON is Important in Networking
- Automation: Scripts can read/write JSON to configure devices.
- APIs: Devices send data in JSON for monitoring or management.
- Controllers: SDN controllers exchange device states in JSON.
- Consistency: Everyone (humans and machines) can understand the same format.
✅ Key points to remember for CCNA 200-301 exam:
- JSON is lightweight, text-based, and used to exchange data.
- Objects =
{}, Arrays =[]. - Values can be string, number, boolean, null, object, or array.
- Keys must be strings in double quotes, separated from values by
:. - JSON can be nested for complex data structures.
