SlideShare a Scribd company logo
1 of 26
YAML
Date : 10-Mar-2017 By:
Sabarinath Gnanasekar
What is YAML?
• YAML is a Data Serialization Language.
• A New Language for Data
• Modeled after Perl-like structures
• But not just intended for Perl
• Human friendly, cross language, Unicode based data serialization language.
• YAML can be taken as an acronym for either
• Yet Another Markup Language
• YAMLAin’t Markup Language
• Like JSON, the purpose of YAML is to represent typical data types in human-
readable notation
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.
YAML Design Goals
YAML design goals:
• - YAML documents are very readable by humans.
• - YAML interacts well with scripting languages.
• - YAML uses host languages native data structures.
• - YAML has a consistent information model.
• - YAML enables stream-based processing.
• - YAML is expressive and extensible.
• - YAML is easy to implement.
Design consideration
• To achieve Human/Computer easy processing
• High Data/Markup (Signal/Noise) Ratio
• To be the world's best Data::Dumper
• To be great for Configs, Caches, and Logs
• Unicode based
• Speedy parsing
• Alternative to XML (for some applications)
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>
• YAML files should end in .yaml
• YAML is case sensitive.
• YAML does not allow the use of tabs. Spaces are used instead as tabs are not
universally supported.
YAML Syntax Basics
• Collections
• Streams and Documents
• Mappings (hashes / dictionaries)
• Sequences (arrays / lists)
• Comments
Contd..
• Scalars (strings,integers, dates and other atomic data types)
oSimple
oQuoted
oBlock ( |)
oFolded
oWiki
oEscaping
• Anchors & Aliases (&,*)
• Tags (Data types)(“!”)
• Nodes -YAML nodes have content of one of three kinds: scalar, sequence, or
mapping. In addition, each node has a tag which serves to restrict the set of
possible values which the node's content can have.
Collections:
• YAML's block collections use indentation for scope and begin each
entry on its own line.
Structures – Streams & Documents
YAML uses three dashes (“---”) to separate documents within a stream. Three
dots ( “...”) indicate the end of a document without starting a new one
• A question mark and space (“? ”) indicate a complex mapping key.
• & and * indicate Anchors and Aliases
Mappings
• A YAML mapping is like a Perl hash
• Unordered Key/Value pairs
• Separated by ': ' (space is mandatory)
---
name: Benjamin
rank: Private
serial number: 1234567890
12:34 PM: My favorite time
Sequences
• A YAML sequence is like a Perl array
• An ordered collection of data
• YAML has a bullet like syntax '- '
---
- red
- white
- blue
- pinko
Examples
---
Fruits:
- Apples
- Tomatoes
Veggies:
- Spinach
- Broccoli
Meats:
- Burgers
- Shrimp
Household:
- Candles
- Incense
- Toilet Duck
Ex2:The Matrix
---
-
- 3
- 5
- 7
-
- 0
- 0
- 7
-
- 9
- 1
- 1
Comments
• Comments/blank lines can go almost anywhere
• Must not be ambiguous with content
• Comments begin '# '
# comment before document
--- #DIRECTIVE # comment
foo: bar # inline comment
phone: number #555-1234
### Comment
fact: fiction
---
blue: bird
# Comment
Scalars
• A YAML scalar is strings,integers, dates and other atomic data
types.
• YAML has many scalar forms.
---
simple: look ma, no quotes
quoted:
- 'Single quoted. Like Perl, no escapes'
- "Double quotes.nLike Perl, has escapes"
- |
A YAML block scalar.
Much like Perl's
here-document.
Scalar content can be written in block form using a literal style (“|”) where all line
breaks count. Or they can be written with the folded style (“>”) where each line
break is folded to a space unless it ends an empty or a “more indented” line.
Tags
• http://yaml.org/type/
• YAML Pros:
• Cleaner format
• Safe deserialization
• Hashes sorted by default
• Supports GLOB(*.txt), Regexp
• Interacts with Ruby, Python, Java etc
Demo
https://gsabarinath91@bitbucket.org/gsabarinath91/serialisation.git
References:
• https://learnxinyminutes.com/docs/yaml/
• http://pyyaml.org/wiki/PyYAMLDocumentation
• http://yaml.org/refcard.html
• http://sangsoonam.github.io/2017/03/13/yaml-vs-json.html

More Related Content

What's hot

Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
Docker, Inc.
 

What's hot (20)

Docker 101: Introduction to Docker
Docker 101: Introduction to DockerDocker 101: Introduction to Docker
Docker 101: Introduction to Docker
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
DevOps with Ansible
DevOps with AnsibleDevOps with Ansible
DevOps with Ansible
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Jenkins
JenkinsJenkins
Jenkins
 
Intro to containerization
Intro to containerizationIntro to containerization
Intro to containerization
 
Svelte JS introduction
Svelte JS introductionSvelte JS introduction
Svelte JS introduction
 
Comprehensive Terraform Training
Comprehensive Terraform TrainingComprehensive Terraform Training
Comprehensive Terraform Training
 
Configuration Management in Ansible
Configuration Management in Ansible Configuration Management in Ansible
Configuration Management in Ansible
 
Gradle - the Enterprise Automation Tool
Gradle  - the Enterprise Automation ToolGradle  - the Enterprise Automation Tool
Gradle - the Enterprise Automation Tool
 
Go Book - Fonksiyonlar, Metotlar, Arayüzler ve Yapılar
Go Book - Fonksiyonlar, Metotlar, Arayüzler ve YapılarGo Book - Fonksiyonlar, Metotlar, Arayüzler ve Yapılar
Go Book - Fonksiyonlar, Metotlar, Arayüzler ve Yapılar
 
An Introduction To Jenkins
An Introduction To JenkinsAn Introduction To Jenkins
An Introduction To Jenkins
 
Introduction to ansible
Introduction to ansibleIntroduction to ansible
Introduction to ansible
 
Maven
MavenMaven
Maven
 
Jenkins Pipelines
Jenkins PipelinesJenkins Pipelines
Jenkins Pipelines
 
Docker swarm
Docker swarmDocker swarm
Docker swarm
 
Atomicity In Redis: Thomas Hunter
Atomicity In Redis: Thomas HunterAtomicity In Redis: Thomas Hunter
Atomicity In Redis: Thomas Hunter
 
Introduction to Docker Compose
Introduction to Docker ComposeIntroduction to Docker Compose
Introduction to Docker Compose
 
Introduction to jenkins
Introduction to jenkinsIntroduction to jenkins
Introduction to jenkins
 

Similar to Yaml (20)

Xml unit1
Xml unit1Xml unit1
Xml unit1
 
XML
XMLXML
XML
 
Introduce to XML
Introduce to XMLIntroduce to XML
Introduce to XML
 
XML-Extensible Markup Language
XML-Extensible Markup Language XML-Extensible Markup Language
XML-Extensible Markup Language
 
BITM3730 10-18.pptx
BITM3730 10-18.pptxBITM3730 10-18.pptx
BITM3730 10-18.pptx
 
BITM3730 10-31.pptx
BITM3730 10-31.pptxBITM3730 10-31.pptx
BITM3730 10-31.pptx
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
Introduction to XML.ppt
Introduction to XML.pptIntroduction to XML.ppt
Introduction to XML.ppt
 
Xml
XmlXml
Xml
 
Xml passing in java
Xml passing in javaXml passing in java
Xml passing in java
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Unit3wt
Unit3wtUnit3wt
Unit3wt
 
Avro intro
Avro introAvro intro
Avro intro
 
Xml iet 2015
Xml iet 2015Xml iet 2015
Xml iet 2015
 
Web Service Workshop - 3 days
Web Service Workshop - 3 daysWeb Service Workshop - 3 days
Web Service Workshop - 3 days
 
Xml
XmlXml
Xml
 
332 ch07
332 ch07332 ch07
332 ch07
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Unit iv xml dom
Unit iv xml domUnit iv xml dom
Unit iv xml dom
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Recently uploaded (20)

Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

Yaml

  • 1. YAML Date : 10-Mar-2017 By: Sabarinath Gnanasekar
  • 2. What is YAML? • YAML is a Data Serialization Language. • A New Language for Data • Modeled after Perl-like structures • But not just intended for Perl • Human friendly, cross language, Unicode based data serialization language.
  • 3. • YAML can be taken as an acronym for either • Yet Another Markup Language • YAMLAin’t Markup Language • Like JSON, the purpose of YAML is to represent typical data types in human- readable notation
  • 4. 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.
  • 5. YAML Design Goals YAML design goals: • - YAML documents are very readable by humans. • - YAML interacts well with scripting languages. • - YAML uses host languages native data structures. • - YAML has a consistent information model. • - YAML enables stream-based processing. • - YAML is expressive and extensible. • - YAML is easy to implement.
  • 6. Design consideration • To achieve Human/Computer easy processing • High Data/Markup (Signal/Noise) Ratio • To be the world's best Data::Dumper • To be great for Configs, Caches, and Logs • Unicode based • Speedy parsing • Alternative to XML (for some applications)
  • 7. 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> • YAML files should end in .yaml • YAML is case sensitive. • YAML does not allow the use of tabs. Spaces are used instead as tabs are not universally supported.
  • 8. YAML Syntax Basics • Collections • Streams and Documents • Mappings (hashes / dictionaries) • Sequences (arrays / lists) • Comments
  • 9. Contd.. • Scalars (strings,integers, dates and other atomic data types) oSimple oQuoted oBlock ( |) oFolded oWiki oEscaping • Anchors & Aliases (&,*) • Tags (Data types)(“!”) • Nodes -YAML nodes have content of one of three kinds: scalar, sequence, or mapping. In addition, each node has a tag which serves to restrict the set of possible values which the node's content can have.
  • 10. Collections: • YAML's block collections use indentation for scope and begin each entry on its own line.
  • 11. Structures – Streams & Documents YAML uses three dashes (“---”) to separate documents within a stream. Three dots ( “...”) indicate the end of a document without starting a new one
  • 12. • A question mark and space (“? ”) indicate a complex mapping key. • & and * indicate Anchors and Aliases
  • 13. Mappings • A YAML mapping is like a Perl hash • Unordered Key/Value pairs • Separated by ': ' (space is mandatory) --- name: Benjamin rank: Private serial number: 1234567890 12:34 PM: My favorite time
  • 14. Sequences • A YAML sequence is like a Perl array • An ordered collection of data • YAML has a bullet like syntax '- ' --- - red - white - blue - pinko
  • 15. Examples --- Fruits: - Apples - Tomatoes Veggies: - Spinach - Broccoli Meats: - Burgers - Shrimp Household: - Candles - Incense - Toilet Duck
  • 16. Ex2:The Matrix --- - - 3 - 5 - 7 - - 0 - 0 - 7 - - 9 - 1 - 1
  • 17. Comments • Comments/blank lines can go almost anywhere • Must not be ambiguous with content • Comments begin '# ' # comment before document --- #DIRECTIVE # comment foo: bar # inline comment phone: number #555-1234 ### Comment fact: fiction --- blue: bird # Comment
  • 18. Scalars • A YAML scalar is strings,integers, dates and other atomic data types. • YAML has many scalar forms. --- simple: look ma, no quotes quoted: - 'Single quoted. Like Perl, no escapes' - "Double quotes.nLike Perl, has escapes" - | A YAML block scalar. Much like Perl's here-document.
  • 19. Scalar content can be written in block form using a literal style (“|”) where all line breaks count. Or they can be written with the folded style (“>”) where each line break is folded to a space unless it ends an empty or a “more indented” line.
  • 21. • YAML Pros: • Cleaner format • Safe deserialization • Hashes sorted by default • Supports GLOB(*.txt), Regexp • Interacts with Ruby, Python, Java etc
  • 22.
  • 23.
  • 24.
  • 26. References: • https://learnxinyminutes.com/docs/yaml/ • http://pyyaml.org/wiki/PyYAMLDocumentation • http://yaml.org/refcard.html • http://sangsoonam.github.io/2017/03/13/yaml-vs-json.html