YAML an intuitive choice for many software developers

YAML is particularly popular in configuration files and in environments where people need to read and write data frequently. It supports complex data structures such as sequences (lists), associative arrays (maps), and scalar values (strings, numbers, Booleans). Its syntax is designed to be clear and unambiguous, making YAML an intuitive choice for many developers.

Clean, simple structuring of data including support for scalar and complex data types

The language promotes clean, simple structuring with indentation and supports both scalar and complex data types. This makes them flexible and versatile for a wide range of applications, from simple configuration files to complex data models.

YAML features

Important features of YAML are

  • Human readability: The clear structure and syntax aim to be understandable and editable even for non-programmers.
  • Cross-platform compatibility: YAML can be processed in any programming language, with many available libraries and tools.
  • Indentation for structuring: Similar to Python, YAML uses indentation to display hierarchical data structures, which improves readability.
  • Support for complex data structures: It can display nested lists, associative arrays and scalar types.
  • Compact representation: Although it is optimized for readability, YAML also allows for compact representation of data, which can be useful when transmitting over networks.

These features make YAML a popular choice for configuration management, application deployment, and many other tasks in software development and beyond.

YAML for serializing data

YAML is therefore not just another markup language, i.e. a machine-readable language for structuring and formatting text and other data like HTML, but for
serialization of data
designed for serializing data.

YAML is based on Unicode

YAML is a human-friendly, cross-language, Unicode-based data serialization language.

YAML increases the interoperability of software

YAML thus complements common native data types of dynamic programming languages and serves as a kind of link between different technologies.

YAML is versatile

The serialization language is suitable for a wide range of programming requirements:

  • Configuration files
  • Internet messaging
  • Object persistence
  • Data check
  • Data visualization

Together with the Unicode standard for characters, the specification provides all the necessary information to create interoperable software programs and APIs that can process YAML information.

YAML - Serialization of data

YAML – Serialization of data

What is the YAML specification for?

YAML is often used for the configuration of software and is also a complete data serialization language.

  • The current YAML specification is version v1.2.2.
  • The YAML specifications define the YAML data language.

The YAML language uses an open and transparent concept so that not only developers but also all other stakeholders can get involved in IT projects more easily.

Markdown as YAML input format

The YAML input format is now Markdown. Images are created from simple LaTeX files.

Since the previous YAML specification over 12 years ago, the popularity of YAML has increased considerably.

YAML simplifies software development and deployment processes

YAML simplifies the development process for software developers and DevOps by using easy-to-understand code artifacts that are easy for humans to read.

YAML simplifies software development and deployment processes

YAML simplifies software development and deployment processes

What is the YAML framework?

In addition, there is the YAML framework as accompanying documentation, which is intended to serve as a guide for implementers of the YAML framework and users of the YAML language.

The result is a language for serializing data that has been designed to be human-friendly and works particularly well with all modern programming languages for everyday tasks.

Why is YAML so successful?

Open, interoperable and easy-to-understand tools have advanced computer technologies immensely. YAML was designed from the start to be useful and friendly for people who work with data.

YAML - One Pass Processing of YAML Code

YAML – One Pass Processing of YAML Code

Structural information plus data

It uses printable Unicode characters, some of which provide structural information and the rest contain the data itself.

This gives YAML files a unique clarity by minimizing the number of structural characters and presenting data in a natural and meaningful way.

How the YAML syntax works

  • Indentations can be used for structuring
  • Colons separate key/value pairs
  • Hyphens are used to create “bulleted lists”.

YAML data structures are simple

There are many types of data structures, but they can all be adequately represented with three basic primitives:

  • Mappings (hashes/dictionaries),
  • sequences (arrays/lists) and
  • Scalars (Strings/Numbers)

YAML uses these primitives and supplements them with a simple typing system and an aliasing mechanism to create a complete language for serializing any native data structures.

While most programming languages can use YAML for data serialization, YAML is characterized by its cooperation with those languages that are fundamentally built on the three basic primitives.

These include common dynamic languages such as JavaScript, Perl, PHP, Python and Ruby.

Only a few programming languages are suitable for data transfer

There are hundreds of different programming languages, but only a handful of languages for storing and transferring data. Although the possibilities of YAML are almost unlimited, it was developed specifically for common use cases, such as configuration files, log files, cross-process messaging, cross-language data exchange, object persistence and debugging of complex data structures.

When data is easy to see and understand, programming becomes easier.

YAML design goals

The design goals for YAML are, in descending order of priority:

  1. YAML should be easily readable by humans.
  2. YAML data should be portable between programming languages.
  3. YAML should match the native data structures of dynamic languages.
  4. YAML should have a consistent model to support generic tools.
  5. YAML should support one-pass processing.
  6. YAML should be expressive and expandable.
  7. YAML should be easy to implement and use.

Code example YAML Logfile

---
Time: 2021-11-23 15:01:42 -5
User: ed
Warning:
  This is an error message
  for the log file
---
Time: 2021-11-23 15:02:31 -5
User: ed
Warning:
  A slightly different error
  message.
---
Date: 2021-11-23 15:03:17 -5
User: ed
Fatal:
  Unknown variable "bar"
Stack:
- file: TopClass.py
  line: 23
  code: |
    x = MoreObject("345\n")
- file: MoreClass.py
  line: 58
  code: |-
    foo = bar
YAML - JSON - XML in comparison - The popular formats for data exchange in the ultimate comparison

YAML – JSON – XML in comparison – The popular formats for data exchange in the ultimate comparison

YAML vs. JSON vs. XML

Our comparison of YAML with other popular data exchange formats such as JSON (JavaScript Object Notation) and XML (Extensible Markup Language) provides important insights into their respective strengths and weaknesses.

Here is our detailed comparison:

Commonalities:

  • Both are human-readable: they offer a clear structure that makes it easy to understand and process the data.
  • Support for basic data types: Both formats support similar data types such as strings, numbers, booleans, arrays (in YAML sequences) and objects (in YAML maps).

Differences:

  • Readability: YAML is known for its readability and clarity, as it uses fewer brackets and instead relies on indentation. JSON, on the other hand, uses many brackets and is more compact, which sometimes makes it harder to read.
  • Comments: YAML supports comments within the code, which is not the case with JSON. This can be useful for documentation purposes.
  • Complexity: YAML can appear subjectively more complex due to its dependence on indentation, especially for deeply nested structures. JSON is very predictable in its structure and often easier to analyze.
  • Parsing: JSON parsers tend to be faster and more universally available due to the simpler format.

YAML vs. XML:

Commonalities:

  • Flexibility: Both formats can represent complex, nested data structures and are often used for configuration files and data exchange.
  • Extensibility: Both YAML and XML can be extended and customized to meet different requirements.

Differences:

  • Verbosity: XML is much more verbal and uses opening and closing tags, which makes it less compact than YAML. YAML is more concise and often clearer in its presentation.
  • Structuring: YAML uses indentation for structuring, while XML uses tags and attributes. This can make YAML more readable in some cases, while XML provides a clearly defined hierarchy and schema support.
  • Data model: XML is not only a data format, but also a document format, which makes it ideal for complex document structures. YAML, on the other hand, concentrates more on data representation.
  • Security: XML is vulnerable to certain types of attacks such as XML External Entity (XXE) attacks, while YAML has its own security considerations, especially when poorly implemented.

Conclusion of our comparison of the currently most popular data exchange formats:

YAML:

  • Strengths: Human readability, compactness, and simplicity in the presentation of complex data.
  • Weaknesses: Potential complexity due to indentation, less universal parser availability.

JSON:

  • Strengths: Fast parsing, universal usability, format consistency.
  • Weaknesses: Less readable for complex data, no built-in comment function.

XML:

  • Strengths: Strict structure, support for complex documents, schema validation.
  • Weaknesses: Verbality, potential security risks, less human-readable for simple data.

The choice between these formats ultimately depends on the specific requirements of the project, the team’s preferred way of working and the type of data to be represented. YAML is often the preferred choice for configuration files and scenarios where readability is critical, while JSON and XML dominate in various other contexts, including web services and complex document structures.

YAML, JSON, XML: Discover the ideal format for your data!

Here is our comparison clearly laid out in a table of the properties of YAML, JSON and XML, highlighting their differences and similarities:

Feature YAML JSON XML
Format Human readable, text-based Text-based, easily machine-readable Verbal, text-based
Readability High (clear and simple) Medium (compact, but many brackets) Low (detailed tags)
Structuring Indentations Parentheses and commas Tags and attributes
Comments Supported Not supported Supported
Complexity Can be complex with deep nesting Relatively simple and predictable Can be complex, especially with namespaces
Parsing Varies (depending on the implementation) Quick and easy Varies, tends to be slower
Data model Data representation Data representation Data and document format
Security Susceptible to poor implementations Relatively safe Vulnerable to XXE attacks
Expandability Flexible Limited Very flexible, supports schemes
Distribution Frequently in configuration files and DevOps Widely used in web APIs and configurations Formerly dominant, especially in enterprise applications

Our table provides a basic overview of the properties and differences between YAML, JSON and XML. However, it is important to note that the best choice for a particular project depends on many factors, including specific requirements, environment and personal or team preferences.