<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[YAML]]></title><description><![CDATA[YAML]]></description><link>https://markuplanguage.hashnode.dev</link><image><url>https://cdn.hashnode.com/uploads/logos/69a550a6fde59e46a4b76857/87c74150-de8c-44a4-9832-b6f3047b9e3c.png</url><title>YAML</title><link>https://markuplanguage.hashnode.dev</link></image><generator>RSS for Node</generator><lastBuildDate>Tue, 08 Sep 2026 20:34:38 GMT</lastBuildDate><atom:link href="https://markuplanguage.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[YAML Ain’t Markup Language: A Beginner’s Guide to YAML with Examples]]></title><description><![CDATA[Let's begin with having brief idea of "what is markup language?",in simple terms markup language is used for having parent and child relationship among different entities or components , just like in ]]></description><link>https://markuplanguage.hashnode.dev/yaml-ain-t-markup-language-a-beginner-s-guide-to-yaml-with-examples</link><guid isPermaLink="true">https://markuplanguage.hashnode.dev/yaml-ain-t-markup-language-a-beginner-s-guide-to-yaml-with-examples</guid><category><![CDATA[YAML]]></category><category><![CDATA[Devops]]></category><category><![CDATA[Open Source]]></category><category><![CDATA[Beginner Developers]]></category><category><![CDATA[General Programming]]></category><dc:creator><![CDATA[Shankar rao S Patil]]></dc:creator><pubDate>Fri, 06 Mar 2026 13:07:40 GMT</pubDate><content:encoded><![CDATA[<p>Let's begin with having brief idea of "what is markup language?",in simple terms markup language is used for having parent and child relationship among different entities or components , just like in HTML. Markup language makes use of tags.</p>
<pre><code class="language-plaintext">&lt;html&gt;
  &lt;body&gt;
     &lt;p&gt;....&lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>From above code we can infer that , child lives in parent tag ... so this is what is parent and child relationship.</p>
<p><strong>We got to understand "What is data serialisation?"</strong></p>
<p>-Its the process of converting data object present in complex datastructures into stream of bytes(chunks of data) and the reverse process of converting the stream of bytes into data object is known as deserialisation.</p>
<p>-Now you might be confused or struck by reading the terms mentioned in the definition. In simple words what it means is that , in OOP we have classes which occupy no memory but are template for the objects to be created so these are very complex and these are found in all the applications. We convert these objects into simple stream of bytes and thats serialisation.</p>
<p>-These convereted streams of bytes can be stored in memory,database ,YAML file or transmited over network.</p>
<p><strong>Lets dive into YAML by first knowing its charactersics</strong></p>
<ol>
<li><p>Used for data format during the exchange of data</p>
</li>
<li><p>Its similar to JSON but not JSON</p>
</li>
<li><p>We can only store data and not commands like if-else etc</p>
</li>
</ol>
<p><strong>Now lets have look at benefits of having YAML</strong></p>
<ol>
<li><p>Simple and easy to read</p>
</li>
<li><p>Having a strict syntax wrt indentation</p>
</li>
<li><p>Easily convertible to JSON or XML</p>
</li>
<li><p>More powerfull when representing complex data</p>
</li>
<li><p>Various tools are available easily for converting these files</p>
</li>
</ol>
<h1>Into YAML</h1>
<p>-YAML files are saved with an extention of .yaml or .yml</p>
<p>NOTE : YAML is case sensitive</p>
<pre><code class="language-plaintext">---
"apple" : "I am an red fruit"
1 : "Its myroll number"

lists:
 - apple
 - banana
 - Apple

cities:
 - New delhi
 - Banglore
...
</code></pre>
<p>The above is an example of simple YAML file and here you can observe , its just similar to key-value pair. Wait....did u observe one more thing? beginning of the document is represented by --- and end of document is represented by ... . The JSON equivalent of the above YAML is as under [I used <a href="https://onlineyamltools.com/convert-yaml-to-json">https://onlineyamltools.com/convert-yaml-to-json</a> for easy convertion]</p>
<pre><code class="language-plaintext">{
  "1": "Its myroll number",
  "apple": "I am an red fruit",
  "lists": [
    "apple",
    "banana",
    "Apple"
  ],
  "cities": [
    "New delhi",
    "Banglore"
  ]
}
</code></pre>
<p>Lets dive into knowing different datatypes used in YAML through code snippets</p>
<pre><code class="language-plaintext">#Strings
Myname : Shankar
Fruit : "Apple"
Job : 'SDE'

#Numbers
rollno : 736
marks : 89.5

#Booleanvalue
istechie : true 
</code></pre>
<p>Here in above example we saw different datatypes but had not explicitely mentioned name of the datatype but there is provision to mention that as well.Lets see that with example</p>
<pre><code class="language-plaintext">#Integer
zero : !!int 0
positivenumber : !!int 896
binarynumber : !!int 0b11010
octalnumber : !!int 06574
hexadecimalnumber :  !!int 0x45
commavalue : !!int +540_350

#Float
simplenum : !!float 56.89
infinite : !!float .inf

notanum : .nan

#Strings
msg : !!str this is  a message
greet : !!str good morning

#Boolean
isTrue : !!bool true
isFalse : !!bool false

#Null
surname : !!null null
firstname : !!null ~
</code></pre>
<p>Now will have a look at how do we srite multiline strings or a very lengthy string that will take more than a line</p>
<pre><code class="language-plaintext">message : &gt;
 this will
 all be in 
 one line 

#above line is equivalent to the below snippet

message : this will all be in one line 
</code></pre>
<p>We got an better idea of what are the datatypes used in YAML file. Why don't we look at advanced datatypes like sequence , set , dictionary ? Below are few code samples</p>
<pre><code class="language-plaintext">#Sequence
student : !!seq
 - marks
 - name 
 - r_no

#Nested sequence 
fruits :
 -
  - mango
  - apple
 -
  - banana
  - grapes

#Key value pairs in the YAML are called as maps
#NestedMapping
name : Srujan
role : {age : 24 , job  : SDE}

#Pairs - here keys may have duplicate values
jobs : !!pairs
 - job : student
 - job : intern

#Set - it will allow us to have unique values
names : !!set
 ? john
 ? darry
 ? mitchell

#Dictionary
friends : !!omap
 - john :
    - age : 22
    - hobby : reading books
 - darry :
    - age : 23
    - hobby : listening music
</code></pre>
<p>Below is the JSON conversion of above code snippet for better understanding of concept</p>
<pre><code class="language-plaintext">{
  "student": [
    "marks",
    "name",
    "r_no"
  ],
  "fruits": [
    [
      "mango",
      "apple"
    ],
    [
      "banana",
      "grapes"
    ]
  ],
  "name": "Srujan",
  "role": {
    "age": 24,
    "job": "SDE"
  },
  "jobs": [
    [
      "job",
      "student"
    ],
    [
      "job",
      "intern"
    ]
  ],
  "names": {
    "john": null,
    "darry": null,
    "mitchell": null
  },
  "friends": [
    {
      "john": [
        {
          "age": 22
        },
        {
          "hobby": "reading books"
        }
      ]
    },
    {
      "darry": [
        {
          "age": 23
        },
        {
          "hobby": "listening music"
        }
      ]
    }
  ]
}
</code></pre>
<p>Oof !! I wrote many things and you read a lot but it would be much more understanding if we can take example and then parse whats written in XML , JSON and YAML files. Will try to make mentioned files out of the digram being shown in the image</p>
<img src="https://cdn.hashnode.com/uploads/covers/69a550a6fde59e46a4b76857/c1febbff-b2b3-4435-92d6-2cf50c40cc75.jpg" alt="" style="display:block;margin:0 auto" />

<pre><code class="language-plaintext">#XML 
&lt;?XML version="1.0" encoding="UTF-8"?&gt;
&lt;School Name="SPD" Principal="Someone"&gt;
  &lt;Students&gt;
    &lt;Student&gt;
      &lt;r_number&gt;3&lt;/r_number&gt;
      &lt;name&gt;Sham&lt;/name&gt;
    &lt;/Student&gt;
  &lt;/Students&gt;
&lt;/School&gt;


#JSON
{
  "School": [
    {
      "Name": "SPD"
    },
    {
      "Principal": "Someone"
    },
    {
      "Students": [
        {
          "Student": [
            {
              "r_number": 3
            },
            {
              "name": "Sham"
            }
          ]
        }
      ]
    }
  ]
}


#YAML
School :  
 - Name : SPD
 - Principal : Someone
 - Students :
    - Student :
       - r_number : 3
       - name : Sham
</code></pre>
<p>So thats it. A big shoutout to <a href="https://hashnode.com/@kunalk" class="user-mention" data-type="mention" title="Kunal Kushwaha">Kunal Kushwaha</a> for encouraging me to make open source contributions and now am here writing my first blog.</p>
]]></content:encoded></item></channel></rss>