Data Encoding Formats – Automation

By | 03/20/2021

As systems communicate with each other, there needs to be a structure behind what is communicated. Simple formatted text that is presented with show commands on a Cisco device will not work. However, systems can easily parse and work with data that is encoded in XML and JSON formats.

JSON

JavaScript Object Notation (JSON) is a lightweight data-interchange text format. It is language independent and is fairly easy to read and write and fairly easy for systems to understand and process. JSON is extremely popular, and for Python developers, it natively maps into Python as a Python dictionary. For example, take a look at the syntax that JSON uses for objects and arrays:

  • Collections name/value pairs
    • Object { }
  • Ordered list of values
    • Array [ ]
    • Figure 12-1 shows a simple example of JSON-formatted text.

Figure 12-1 JSON Example

XML

Extensible Markup Language (XML) is a markup language similar to HTML that was designed to store and transport data. XML is data wrapped in tags and is both human readable and system readable. For example, notice the tags used to start and end text:

  • Beginning and ending tags
    • <text>Hello, world!</text>
  • Hierarchy of tags
    • Start tags <tx><houston>
    • End tags </houston></tx>
    • Figure 12-2 shows an example of XML for a Gigabit Ethernet interface.

Figure 12-2 XML Example

Data Models

A data model can be thought of as a well-understood and agreed-upon way of describing something. A data model describes a controlled set of data, using well-defined parameters to standardize the representation of data. Let’s consider an example of houses for sale. Here is a possible data model for houses for sale:

  • Location: Houston, TX or Austin, TX
  • Bedrooms: 3–5 bedrooms
  • Square feet: 2500 to 5500
  • Total Bathrooms: 2–3 Full and 1–2 Half
  • Lot size: .25 acres to 7 or more acres
  • Property Type: Singe Family, Condo, or Multi-Family
  • Price: $149,000 to $675,000

Model-Driven Programmability Stack

Model-driven programmability provides several advantages, including flexibility and modularity. Model-driven programmability is model based, structured, and system friendly. It provides support for multiple model types, from native and common to OpenConfig and IETF industry standards. Furthermore, models are decoupled from transport, protocols, and encoding. Model-driven APIs allow for abstraction and simplification.

In Figure 12-3, the model-driven programmability stack consists of six layers. At the bottom are YANG data models that are both native and open. Next are two transport protocols: SSH and HTTP. Above that is the protocol layer, including NETCONF, RESTCONF, and gRPC. The encoding layer has both JSON and XML. The API layer is next, with model-driven APIs using YANG. Finally, apps are at the top of the stack. We explore several of these components further in this chapter.

Figure 12-3 Model-Driven Programmability Stack

Leave a Reply

Your email address will not be published. Required fields are marked *