50%

YAML Cheat Sheet

A YAML cheat sheet is a quick reference guide that provides an overview of the syntax and critical features of YAML. It is a handy reference for developers and users working with YAML files that need a reminder of the syntax rules and common patterns. This cheat sheet provides a quick overview of basic YAML syntax, including key-value pairs, strings, numbers, booleans, arrays, nested objects, multiline strings, anchors, aliases, and null values.

1. Basic :-

Comments
# A single line comment example
# block level comment example
# comment line 1
# comment line 2
# comment line 3
Scalar Types
m1: 3 # integer
m2: 3.96 # float
p1: 'xyz' # string
p2: "xyz" # string
p3: xyz # string
a: true # boolean type
d: 2015-04-05 # date type
Inheritance
parent: &defaults
 a: 6
 b: 9
                                              
child:
 <<: *defaults
 b: 3
Variables
new_thing: &VAR_NAME foobar
some_thing: *VAR_NAME
Multiline
strings
description: |
  Hello
  YAML
Two
Documents
---
document: This is document 1
---
document: This is document 2
YAML uses --- to split directions from document content.

2. YAML Collections :-

Unordered
Sets
set1: !!set
  ? hello
  ? world
set2: !!set {'hello', "world"}
Ordered
Mappings
ordered: !!omap
 - Cristiana Gillis : 60
 - Berniece Denise: 53
 - Merilyn Editha : 48
Mapping to Sequences
attributes:
 - A1
 - A2
methods: [getter, setter]
Sequence of Mappings
children:
  - name: Bradley Garza
    age: 16
  - name: Robert Baker
    age: 11
                                            
Mapping of Mappings
David Edwards: {hr: 54, avg: 0.248}
Anthony Gonzalez: {
    hr: 49,
    avg: 0.235 }

YAML CheatSheet Online


A YAML cheat sheet is a reference guide or quick reference resource that provides a concise overview of the syntax and structure of YAML (YAML Ain't Markup Language). YAML is a human-readable data serialization format generally used for configuration files, data exchange, and defining structured data in a readable format.

A YAML cheat sheet typically includes the following:

  • YAML Syntax: It outlines the basic rules and conventions for writing YAML, such as the use of indentation (spaces or tabs) to represent hierarchy and the colon (:) to separate keys and values.
  • YAML Data Types: It lists the supported data types in YAML, including scalars (strings, numbers, booleans, null), sequences (arrays/lists), and mappings (key-value pairs).
  • YAML Scalars: It explains how to define scalar values in YAML, including strings, numbers, booleans, and null.
  • YAML Sequences: It illustrates how to define sequences (arrays or lists) in YAML, showing examples of items in a sequence.
  • YAML Mappings: It describes how to define mappings (key-value pairs) in YAML, demonstrating the use of keys and values.
  • YAML Anchors and Aliases: It introduces the concept of anchors and aliases in YAML, which allows for reusing or referencing data within a YAML document.
  • YAML Comments: It explains how to add comments to a YAML file, allowing developers to provide additional context or explanations within the YAML structure.
  • YAML Example: It presents a sample YAML structure or snippet to demonstrate how the various elements discussed in the cheat sheet fit together.

The YAML cheat sheet serves as a handy resource for developers, architects, and system administrators who work with YAML files or need to parse YAML data. It equips a quick reference to the syntax and structure of YAML, allowing users to write or understand YAML configurations more efficiently without depending on extensive documentation.

Know more about YAML