10
YAML

Yaml

Embed Size (px)

Citation preview

Page 1: Yaml

YAML

Page 2: Yaml

YAMLBackground and Purpose

Page 3: Yaml

What is YAML?• Human friendly, cross language, Unicode based data

serialization language.• Pronounced in such a way as to rhyme with “camel”• Acronym for

YAML

Ain’t

Markup

Language

Page 4: Yaml

What is a data serialization language?

• A language used to convert or represent structured data or objects as a series of characters that can be stored on a disk.

• Examples:• CSV – Comma separated values• XML – Extensible markup language• JSON – JavaScript object notation• YAML – YAML ain’t markup language

Page 5: Yaml

Why YAML if XML?• Unlike XML which is not easily readable by humans,

YAML was created to be human-friendly and integrate easily with modern programming languages.

• Unlike with XML, YAML was intended to simplify the viewing and understanding of config files, log files, object persistence, and messaging, to allow the programmer to spend more time programming and less time formatting data.

Page 6: Yaml

YAML Design Goals• As stated in the YAML official specification, the design

goals for YAML in decreasing priority are:1. YAML is easily readable by humans

2. YAML data is portable between programming languages

3. YAML matches the native data structures of agile languages.

4. YAML has a consistent model to support generic tools.

5. YAML supports one-pass processing.

6. YAML is expressive and extensible.

7. YAML is easy to implement and use.

Page 7: Yaml

YAMLSyntax and Language Elements

Page 8: Yaml

Basic YAML Syntax Rules• Documents begin with --- and end with …• Indentation of lines denotes the structure within the

document.• Comments begin with #• Members of lists begin with –• Key value pairs use the following syntax

• <key>: <value>

Page 9: Yaml

Basic YAML Syntax Rules• Example:

---Student-Id: 11223344First-Name: JohnLast-Name: Smith

Phone-numbers: - 281.555.7689 - 713.555.8967 - 832.555.9980

Addresses: - street: 123 Main St. city: Houston state: TX...

Page 10: Yaml

Advanced YAML Syntax• There is more advanced syntaxes that exist that allow

YAML to represent• Relational trees

• *, <<, and & are used for node reference, array merges, and anchoring respectively

• User defined data types

• These are beyond the scope of this introductory tutorial.