Domain 6Automation & ProgrammabilityCORE

Data Serialization Formats

Understanding data serialization formats used in network automation, including JSON, XML, and YAML structures and syntax.

Domain: Domain 6: Automation and Programmability•Updated: 2026-08-26
#JSON#XML#YAML#Serialization#Data Encoding

Data Serialization Languages (JSON, XML, YAML)

Data Serialization Fundamentals

  • Concept: The process of converting data into a standardized format or structure that can be stored (e.g., in a file) or transmitted (e.g., over a network) and reconstructed later by a different application.
  • Purpose: Enables communication between applications written in different programming languages (e.g., Python and Java) by providing a common, standardized data format.
  • Variables: Containers that store values (e.g., interface_name contains gigabitethernet1/1). Serialization translates these variables into standardized text.
sequenceDiagram
    participant Client as Client App (e.g., Python)
    participant API as Server/API (e.g., SDN Controller)
    Client->>API: GET Request
    API->>API: Retrieve native variables
    API->>Client: Serialize to JSON (Standard Format)
    Client->>Client: Deserialize to native format

JSON (JavaScript Object Notation)

  • Concept: An open-standard, language-independent data interchange format that uses human-readable text. It is the primary data serialization format tested on the CCNA (Exam Topic 6.7: interpret JSON encoded data).
  • Details:
    • Standardized in RFC 8259.
    • Frequently used by REST APIs.
    • Whitespace is insignificant: Spaces and line breaks do not change the meaning of the data (used only for human readability).
    • Objects are sometimes referred to as dictionaries.

JSON Data Types

JSON has 4 primitive and 2 structured data types:

Data Type Category Description & Syntax Rules Example
String Primitive Text value. Must be surrounded by double quotes (""). "gigabitethernet1/1"
Number Primitive Numeric value. No quotes. 100, 5
Boolean Primitive Logical value. No quotes. Must be lowercase true or false. true, false
Null Primitive Intentional absence of any object value. No quotes. Lowercase null. null
Object Structured Unordered list of key-value pairs. Surrounded by curly braces {}. Keys must be strings (double quotes). Separated by colons :. Pairs separated by commas ,. {"name": "R1"}
Array Structured Ordered series of values (can be mixed types). Surrounded by square brackets []. Values separated by commas ,. ["Gi1/1", "Gi1/2", 5]
{
  "device": {
    "name": "R1",
    "vendor": "Cisco",
    "model": "1101"
  },
  "interfaces": [
    "gigabitethernet1/1",
    "gigabitethernet1/2",
    "gigabitethernet1/3"
  ],
  "is_up": true,
  "mtu": 1500,
  "description": null
}

Things to note: A trailing comma after the last key-value pair in an object or the last value in an array is invalid JSON and will cause parsing errors.

XML (eXtensible Markup Language)

  • Concept: Originally developed as a markup language, now widely used as a general data serialization language.
  • Details:
    • Whitespace is insignificant.
    • Uses HTML-like tags to denote key-value pairs: <key>value</key>.
    • Frequently used by REST APIs and supported natively in Cisco IOS for command output formatting.
<entry>
  <Interface>GigabitEthernet0/0</Interface>
  <IP-Address>192.168.1.1</IP-Address>
  <OK>YES</OK>
  <Method>manual</Method>
  <Status>up</Status>
  <Protocol>up</Protocol>
</entry>

YAML (YAML Ain’t Markup Language)

  • Concept: A human-readable data serialization language. The name is a recursive acronym.
  • Details:
    • Whitespace is SIGNIFICANT: Indentation strictly defines the structure and hierarchy of the data.
    • Files typically start with three hyphens: ---.
    • Lists are indicated by a hyphen -.
    • Key-value pairs use a colon and a space: key: value.
    • Heavily used in network automation tools like Ansible.
---
device:
  name: R1
  vendor: Cisco
interfaces:
  - gigabitethernet1/1
  - gigabitethernet1/2
is_up: true
mtu: 1500

Comparison: JSON vs. XML vs. YAML

Feature JSON XML YAML
Primary Use REST APIs, Web Data Legacy APIs, Cisco IOS formatting Ansible, Configuration files
Whitespace Insignificant Insignificant Significant (Indentation matters)
Syntax Style Curly {} and Square [] brackets, colons :, quotes "" Angle brackets <tag>value</tag> Hyphens -, colons :, indentation
Human Readability High Moderate (verbose) Very High (clean)
Key Requirement Keys must be double-quoted strings Keys are tag names Keys are plain text followed by :

Common Exam Misconceptions & Traps

  • “Key” is not a data type: In JSON, “key” is a structural concept. The actual data type of a key is always a String.
  • Quotes matter for Booleans: "true" (with quotes) is a String. true (without quotes) is a Boolean.
  • Trailing commas: { "key": "value", } is invalid. Do not place a comma after the final item in an object or array.
  • Bracket matching: Every opening curly brace { or square bracket [ must have a corresponding closing brace } or square bracket ].
  • Array vs. Object: An array [ ] contains a series of values. An object { } contains a series of key-value pairs.

Consolidated Commands & Syntax

! Cisco IOS command to output standard CLI data into XML format
Router# show ip interface brief | format xml
// Valid JSON Key-Value Pair Syntax
"key_name": "string_value"
"numeric_value": 100
"boolean_value": true
"null_value": null
# Valid YAML Syntax
---
key_name: string_value
numeric_value: 100
boolean_value: true
list_item:
  - value1
  - value2