YAML
YAML
Advantages: Human-readable. Has lots of data types.
Overall: Unlike JSON, the YAML format looks more like how someone would write down structured
data on paper. It was designed specifically to be easier for humans to read.
Uses: I used YAML for deployments scripts for CI/CD pipelines and releases in
Microsoft's Azure when I worked at QuikTrip. I have used YAML for settings and
data that were used by programs written in different languages.
Other similar things: YAML is very similar to XML or JSON in its purpose.
Overall Implementation: It uses the following:
Indentation to represent objects
Colons to separate key-value pairs
Hyphens for arrays
Hashes to denote a comment
YAML was originally built to simplify XML.
doe: "a deer, a female deer"
ray: "a drop of golden sun"
pi: 3.14159
xmas: true
french-hens: 3
calling-birds:
- huey
- dewey
- louie
- fred
xmas-fifth-day:
calling-birds: four
french-hens: 3
golden-rings: 5
partridges:
count: 1
location: "a pear tree"
turtle-doves: two
# This is a full line comment
foo: bar # this is a comment, too
Advantage to YAML is all the different built in data types. More than many computer languages.
YAML supports several other numeric types. An integer can be decimal, hexadecimal,
or octal. YAML supports both fixed and exponential floating point numbers.
YAML not-a-number (NAN) or infinity.
YAML treats the \n as two characters such as:
bar: this is not a normal string\n
YAML handles nulls with a tilde(~) or the unquoted null string literal:
foo: ~
bar: null
YAML arrays can be done in braces or multiple lines with preceeding dash:
items: [ 1, 2, 3, 4, 5 ]
names: [ "one", "two", "three", "four" ]
items:
- 1
- 2
- 3
- 4
- 5
names:
- "one"
- "two"
- "three"
- "four"
NOTE - See the blog on YAML with Azure.
Comments
Post a Comment