Tuesday, July 16, 2024

Cisco 134 - JSON, XML, YAML

---------------> JSON <---------------

JavaScript Object Notation
Attempts to strike balance between human-readable & machine readability
{
  “response” : {
    “type” : “Cisco Catalyst 9300”,
    “family” : “Switches”,
    “macAddr” : “f8:7b:20:67:62:80”
  }
}

Key:Value Pair
Value types:
- Text
- Numeric
- { } Object - Series of key:value pairs
- [ ] Array – Series of values (not key:value pairs)

Example of JSON Array:
[
“Fred”,
“Wilma”,
“Barney”
]

Example of JSON Object:
{
    “Parents”: [
        “Fred”,
        “Wilma”,
        “Barney”,
        “Betty”
    ],
    “Children”: [
        “Pebbles”,
        “Bambam”
    ]
}
^ This JSON object has two arrays within.

---

---------------> XML <---------------

eXtensible Markup Language
<?xml version = “1.0”>
<root>
    <blah>
        <blah1>
        <blah2>
        <blah3>
    </blah>
</root>

---

---------------> YAML <---------------

YAML Ain’t Markup Language
Used heavily in Ansible
#Comment about Playbook
-name: Get IOS Facts
    hosts: mylab
    vars:
        host:  “{{ ansible_host }}”
        username: “{{ username }}”
tasks:
    - ios_facts:
        gather_subset: all
        provider: “{{ cli }}”