Learn YAML, JSON vs XML, Summaries of Information Technology

- Learn YAML language syntax, compare with XML and JSON (Slide presentation) - Docker project in task1 ASM2: + Use Dockerfile to build the image + Use Docker-composit to run, manage multiple containers (Web, DB ...)

Typology: Summaries

2020/2021

Uploaded on 08/20/2021

nguoigiauten
nguoigiauten 🇻🇳

2 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
YAML
JSON vs XML
pf3
pf4
pf5
pf8

Partial preview of the text

Download Learn YAML, JSON vs XML and more Summaries Information Technology in PDF only on Docsity!

YAML

JSON vs XML

HOW DATA IS STORED IN YAML

YAML can contain different kinds of data blocks:

  • Sequence: values listed in a specific order. A sequence starts with a dash and a space (). You can think of a sequence as a Python list or an array in Bash or Perl.-
  • Mapping: key and value pairs. Each key must be unique, and the order doesn't matter. Think of a Python dictionary or a variable assignment in a Bash script. There's a third type called , which is arbitrary data (encoded in Unicode) such as strings, integers, dates, and so on. In practice, these are the words and numbers you type when building mapping and sequence blocks, so you won't think about these any more than you ponder the words of your native tongue.scalar When constructing YAML, it might help to think of YAML as either a sequence of sequences or a map of maps, but not both.

YAML syntax

  • YAML has features that come from Perl, C, XML, HTML, and other programming languages. YAML is also a superset of JSON, so JSON files are valid in YAML.
  • YAML uses Python-style indentation to indicate nesting. Tab characters are not allowed, so whitespaces are used instead. There are no usual format symbols, such as braces, square brackets, closing tags, or quotation marks. YAML files use a .yml or .yaml extension.
  • The structure of a YAML file is a map or a list.
  • Maps allow you to associate key-value pairs. Each key must be unique, and the order doesn't matter. Think of a Python dictionary or a variable assignment in a Bash script.
  • A map in YAML needs to be resolved before it can be closed, and a new map is created. A new map can be created by either increasing the indentation level or by resolving the previous map and starting an adjacent map.
  • A list includes values listed in a specific order and may contain any number of items needed. A list sequence starts with a dash (-) and a space, while indentation separates it from the parent. You can think of a sequence as a Python list or an array in Bash or Perl. A list can be embedded into a map.
  • YAML also contains scalars, which are arbitrary data (encoded in Unicode) that can be used as values such as strings, integers, dates, numbers, or booleans.
  • When creating a YAML file, you’ll need to ensure that you follow these syntax rules and that your file is valid. A linter is an application that verifies the syntax of a file. The yamllint command can help to ensure you’ve created a valid YAML file before you hand it over to an application.
  • One of the most common uses for YAML is to create configuration files. It's recommended that configuration files be written in YAML rather than JSON, even though they can be used interchangeably in most cases, because YAML has better readability and is more user-friendly.
  • YAML is also used by the automation tool Ansible to create automation processes, and for Kubernetes resources and deployments.
  • A benefit of using YAML is that YAML files can be added to source control, such as Github, so that changes can be tracked and audited. What is YAML used for?