SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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

Was ist angesagt? (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
 

Ähnlich wie 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
 

Kürzlich hochgeladen

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Kürzlich hochgeladen (20)

Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 

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