Page Content

Tutorials

What is Data Format for Automation and Data Formats Types

What is Data Format?

As standardized ways to describe configuration, state, and operational data, data formats are essential to network automation because they enable dependable information transmission across systems. These formats, sometimes referred to as data modelling languages or data serialization, give programs a common way to describe variables for transmission and storage outside of the program.

JSON, YAML, and XML are the most widely used and significant data formats in this field.

What is Data Format
What is Data Format

You can also read Future of Network Automation and Types of Network Automation

JSON (JavaScript Object Notation)

The most used data format for web services and APIs is JSON. It is an easy-to-understand format that is lightweight and readable by both humans and machines.

  • JSON is the specific data modeling language mentioned in the current CCNA blueprint that requires interpretation skills.
  • Definition and Purpose: JSON is a human-readable data format used by applications for storing, transferring, and reading data. It is widely supported by systems and is easily parsable with most modern programming languages, including Python. JSON is commonly used with REST APIs.
  • Structure and Syntax: JSON structures data into key:value pairs separated by a colon (:).
    • Key:Value Pairs: The key (usually on the left side) identifies the data, and the value (on the right) is the data itself. Both keys and string values must be enclosed in double quotes (").
    • Objects and Arrays: JSON uses specialized data structures to represent complex variables.
      • A JSON object starts and ends with curly brackets ({}) and contains a set of key:value pairs. Objects act similarly to dictionaries in Python.
      • A JSON array starts and ends with square brackets ([]) and contains a list of values. Arrays list a series of values, and if a key’s value is an array, it signifies multiple values for that key. Python converts JSON arrays into lists.
    • Other Syntax Rules: Boolean values must be lowercase (unlike Python, which wants capitalization), and trailing commas must not be used after the last key:value pair. JSON can nest objects and arrays within one another.
    • Readability: JSON can exist in a “minified” format (no whitespace) or a “beautified” format with spacing and alignment to enhance human readability.
  • Data Exchange: JSON is the data format commonly returned when requesting information from the Cisco DNA Center via a REST-based API. Cisco Nexus devices can natively convert show command output to JSON using a pipe command (| json-pretty native).

You can also read Advantages and Disadvantages of Mesh Topology Network

YAML (YAML Ain’t Markup Language)

Among the frequently mentioned serialization languages, YAML is widely regarded as the most readable and user-friendly data serialization standard. Instead of addressing specifics of markup, it concentrates on the structure of data models.

  • Structure and Syntax: YAML’s structure is similar to JSON’s (key-value pairs and lists), but it mostly uses indentation to show hierarchy. It is simple to write and read because of its simple syntax. Additionally, any valid JSON is also valid YAML since YAML is a superset of JSON.
  • Common Use Cases: YAML’s human-readability in configuration files makes it a popular choice. Ansible and other configuration management tools commonly use it. Ansible playbooks and inventories, NetBox device models, Kubernetes network policies, and NAPALM setups are a few examples of specific applications.
  • Pros and Cons: YAML allows comments and offers better human readability. Its main flaw is that indentation can be difficult and cause mistakes. In comparison to JSON, it is also less standardized for direct API calls.

XML (Extensible Markup Language)

XML is a mature format that uses beginning and ending tags (e.g., <value> and </value>) to structure data. It is self-descriptive but generally more verbose than JSON.

  • Structure and Syntax: Hypertext Markup Language (HTML) web pages served as the model for XML. It defines items and characteristics using tags.
  • Common Use Cases: XML is still essential for some standards, even if JSON has mainly replaced it for new APIs. It is widely used in earlier SOAP APIs, some vendor APIs, and protocols like NETCONF and RESTCONF (which frequently use YANG models stored in XML). It works well when highly structured and self-descriptive data is required.
  • Pros and Cons: XML is very reliable, provides namespaces, and includes great validation tools like XML Schemas and DTDs. Its shortcomings include poor human readability, complicated parsing in comparison to JSON/YAML, and excessive verbosity, which leads to enormous file sizes.
AcronymNameCentral PurposeCommon UseStructure Key
JSONJavaScript Object NotationGeneral data modeling and serializationREST APIsKey:value pairs using curly braces {} (objects) and square brackets [] (arrays)
XMLExtensible Markup LanguageData-focused text markup that allows data modelingREST APIs, Web pagesBeginning and ending tags (e.g., <tag>...</tag>)
YAMLYAML Ain’t Markup LanguageGeneral data modelingAnsibleStructured by whitespace; uses simple key-value mappings and lists

You can also read What is Dual Homed Topology Definition and Applications

Specialized and Supporting Data Formats

Two additional formats play specific roles in network automation:

FormatDescriptionBest Use CaseProtocols/Tools
CSV (Comma-Separated Values)A flat data storage method. Simple and easy for non-programmers.Great for bulk operations, such as importing or exporting inventory or IP address plans.IPAM exports, Migration scripts, Inventory automation.
Protocol Buffers (Protobuf)A binary, compact, high-performance format. Extremely fast and saves bandwidth.High-speed, large-scale data exchange.gRPC (used in gNMI environments) and telemetry streaming (Cisco, Juniper, Arista).

The Role of YANG (Yet Another Next Generation)

Although it is not a data format in and of itself, the YANG data modelling language is essential for contemporary network automation.

  • Function: YANG establishes the requirements, syntax, and structure for a network device’s setup and status data. It offers a structured model for the appearance of network data.
  • Relation to Formats: For transmission across protocols like NETCONF or RESTCONF, the data defined by a YANG model is then encoded into one of the popular data formats (JSON, XML, or YAML). YANG ensures that the configuration data follows the format specified by the manufacturer.

Summary of Use Cases

The recommended data format depends on the specific automation task:

  • For API-based automation, JSON is recommended.
  • For Ansible playbooks or configuration-as-code, YAML is the preferred choice.
  • For NETCONF configuration, XML is used.
  • For Controller telemetry streaming, Protobuf/gRPC is utilized.

Data Formats in Context of REST APIs

Data serialization languages are crucial for REST-based Application Programming Interfaces (APIs).

  • Data Exchange Standard: APIs create a way for software applications to communicate by exchanging data. The data formats define how variables (including list and dictionary variables, or data structures) used by a program are communicated as text.
  • API Functions: REST APIs perform fundamental operations often summarized by the CRUD acronym (Create, Read, Update, Delete). For example, the Read action allows a client to retrieve the current value of variables that exist at the server, returning data commonly formatted in JSON or XML.
  • Data Models: Centralized controllers, such as Cisco DNA Center, formalize and define data models for configuration and operational data about networks. This allows programs using the controller’s Northbound APIs to readily access structured data, rather than having to parse unstructured text output from show commands.

The use of data serialization languages enables API servers to return data that allows the API client to accurately replicate the variable names and data structures found on the server, overcoming issues related to how different programming languages internally store variables.

You can also read What is Point To Multipoint Topology Advantages, Common Uses

Hemavathi
Hemavathihttps://govindhtech.com/
Myself Hemavathi graduated in 2018, working as Content writer at Govindtech Solutions. Passionate at Tech News & latest technologies. Desire to improve skills in Tech writing.
Index