YAML Introduction

“YAML Ain’t Markup Language” (abbreviated YAML) was designed from the start to be very human-readable and easy to use and understand. It was specifically created to work well for common use cases such as configuration files and log files. When data is easy to view and understand, programming becomes a simpler task for us humans.

The main design goals for YAML are:

  1. To be easily readable by humans.
  2. To be portable between programming languages.
  3. To match the native data structures of most modern programming languages.
  4. To have a consistent model to support generic tools.
  5. To be expressive and extensible.
  6. To be easy to implement and use.

YAML vs JSON

Both JSON and YAML's main goal as a language is to be human-readable. However, JSON and YAML have different priorities. JSON’s foremost design goal is universality. So, JSON is trivial to generate and parse, at the cost of reduced human readability. It also uses the lowest common denominator information model, ensuring any JSON data can be easily processed by every modern programming environment.

In contrast, YAML’s foremost design goals are human readability. Thus, YAML allows for extremely readable files but is more complex to generate and parse. YAML requires more complex processing when crossing between different programming environments.

---
router1:
    address: 10.1.1.1
    operational: true
    uptime: 46701
    interfaces:
        - GigabitEthernet0/1
        - GigabitEthernet0/2
        - GigabitEthernet0/3
    

Because of its human-friendliness, YAML is one of the most widely used serialization format in Network Automation and SDN products.

Compare the following YAML code to the previous JSON examples. It is basically the same information presented differently.

YAML Structure

As you have already seen, indentation and whitespaces are part of YAML syntax. Unless stated otherwise, end of a line indicates end of a field.

Full Content Access is for Registered Users Only (it's FREE)...

  • Learn any CCNA, DevNet or Network Automation topic with animated explanation.
  • We focus on simplicity. Networking tutorials and examples written in simple, understandable language for beginners.