{"id":1645,"date":"2018-08-13T18:00:00","date_gmt":"2018-08-13T16:00:00","guid":{"rendered":"https:\/\/demo.sidekick.be\/itenium\/yaml-tutorial\/"},"modified":"2025-11-28T13:31:46","modified_gmt":"2025-11-28T12:31:46","slug":"yaml-tutorial","status":"publish","type":"post","link":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/","title":{"rendered":"Yaml tutorial"},"content":{"rendered":"<h1 id=\"yaml-aint-markup-language\">YAML Ain\u2019t Markup Language<\/h1>\n<p>Before we dive into the \u201ccode\u201d:<\/p>\n<ul>\n<li>Extensions: <code>.yaml<\/code>, <code>.yml<\/code><\/li>\n<li>Indenting with spaces. (no tabs!)\n<ul>\n<li>Correct indentation is mandatory!<\/li>\n<li>2 spaces is favored (because it makes arrays align?)<\/li>\n<li>For arrays, the <code>-<\/code> counts as indentation<\/li>\n<\/ul>\n<\/li>\n<li>Keys may contain spaces, and pretty much anything when enclosed within single quotes<\/li>\n<\/ul>\n<p>When unsure what something does exactly, try it online: <a href=\"https:\/\/www.json2yaml.com\/\">json &lt;-&gt; yaml<\/a>!<\/p>\n<h2 id=\"scalars\">Scalars<\/h2>\n<pre><code class=\"language-yml\"># This is a comment\nkey: value\nint: 7\nfloat: 0.5\nbool: true\nnull: null\n<\/code><\/pre>\n<p>This would be equal to the json: <code>{key: 'value', int: 7, float: 0.5, bool: true, null: null}<\/code><\/p>\n<p><strong>Dates<\/strong>:<\/p>\n<pre><code class=\"language-yaml\">dt: 2018-12-18T02:59:43.1Z\ndt_alt: 2017-12-17 16:59:43.10 -5\ndate: 2016-12-16\n<\/code><\/pre>\n<p>Json: <code>{ dt: '2018-12-18T02:59:43.100Z', dt_alt: '2017-12-17T21:59:43.100Z', date: '2016-12-16T00:00:00.000Z' }<\/code><\/p>\n<p><strong>Casting<\/strong>:<\/p>\n<ul>\n<li><code>key: !!str 0.5<\/code> =&gt; \u201c0.5\u201d<\/li>\n<li><code>key: !!float 0<\/code> =&gt; 0.0<\/li>\n<\/ul>\n<h2 id=\"strings\">Strings<\/h2>\n<pre><code class=\"language-yml\"># To be on the safe side, quote all strings\n# that contain any of the following []{}:&gt;|\nstr1: This is a string\nstr2: 'has ''one'' escape'\nstr3: \"has many \", trn\u0000\"\n\n# With preserve extra whitespace starts the current level of indentation.\npreserve: |\n  multi-line\n      with newlines and\n    additional whitespace\n          preserved\n\nfold: &gt;\n  These lines\n  will be folded\n  into a single line\n\n  Blank lines denote\n  paragraph breaks\n<\/code><\/pre>\n<h2 id=\"mappings-and-sequences\">Mappings and Sequences<\/h2>\n<pre><code class=\"language-yaml\">map:\n  name: Billy\n  age: 16\n\nmap_alt: {name: Billy The Kid, age: 16}\n\narray:\n  # To nest arrays, just increase the indenting\n  - 9\n  - true\n  - a string\n\narray_alt: [9, true, a string]\n\narray_map:\n  - id: 5\n    name: Bart\n    hobbies:\n      - Skateboarding\n      - Mischievousness\n  - id: 6\n    name: Maggie\n    traits:\n      lang: null\n      proxy: Marge\n<\/code><\/pre>\n<p>The Json for <code>array_map<\/code>:<\/p>\n<pre><code class=\"language-json\">[{\n    id: 5,\n    name: 'Bart',\n    hobbies: ['Skateboarding', 'Mischievousness']\n}, {\n    id: 6,\n    name: 'Maggie',\n    traits: {lang: null, proxy: 'Marge'}\n}]\n<\/code><\/pre>\n<h2 id=\"anchors\">Anchors<\/h2>\n<p><strong>Using anchors<\/strong>:<\/p>\n<pre><code>billing: &amp;address1\n  street: Brook Street 15\n  town: Davenport\n\nshipping: *address1\n<\/code><\/pre>\n<p>After this, the content of <code>shipping<\/code> is the same as that of <code>billing<\/code><\/p>\n<p><strong>Merge mappings<\/strong><\/p>\n<pre><code class=\"language-yml\">male: &amp;man\n  gender: M\n  age: null\n\nfemale: &amp;woman\n  gender: F\n  age: null\n\nBob:\n  spouse: Alice\n  &lt;&lt;: *man\n  age: 32\n\nCatherine:\n  &lt;&lt;: *woman\n  spouse: Mary\n<\/code><\/pre>\n<p>Json:<\/p>\n<ul>\n<li>Bob: <code>{spouse: 'Alice', gender: 'M', age: 32}<\/code><\/li>\n<li>Catherine: <code>{gender: 'F', age: null, spouse: 'Mary'}<\/code><\/li>\n<\/ul>\n<h2 id=\"other\">Other<\/h2>\n<p><strong>Binary<\/strong>:<\/p>\n<pre><code>gif_file: !!binary |\n  R0lGODdhDQAIAIAAAAAAANn\n  Z2SwAAAAADQAIAAACF4SDGQ\n  ar3xxbJ9p0qa7R0YxwzaFME\n  1IAADs=\n<\/code><\/pre>\n<p><strong>Sets<\/strong>:<\/p>\n<pre><code class=\"language-yml\">set:\n  ? item1\n  ? item2\n  ? item3\n<\/code><\/pre>\n<p>Json: <code>{set: {item2: null, item3: null, item1: null}}<\/code><\/p>\n<h1 id=\"implementations\">Implementations<\/h1>\n<p>I first came into contact with Yaml when using Jekyll, where it is used quite extensively. Aside from Jekyll, it is used for a many things, in Spring, Travis CI, Grav, in the cloud, \u2026 and <a href=\"http:\/\/yaml.org\">parsers are available for all languages<\/a>.<\/p>\n<p>It\u2019s not all <a href=\"https:\/\/github.com\/cblp\/yaml-sucks\">moonshine and roses<\/a> though as the implementations tend to yield different results for more exotic inputs (and sometimes also for not so exotic input).<\/p>\n<p><strong>YamlDotNet<\/strong><br \/><a href=\"https:\/\/github.com\/aaubry\/YamlDotNet\" class=\"github\"><img decoding=\"async\" src=\"https:\/\/img.shields.io\/github\/stars\/aaubry\/YamlDotNet.svg?style=social&amp;label=Star\" \/><\/a><a href=\"https:\/\/github.com\/aaubry\/YamlDotNet\">aaubry\/YamlDotNet<\/a>: For .NET, there is YamlDotNet<\/p>\n<pre><code class=\"language-c#\">Install-Package YamlDotNet\n\nusing YamlDotNet.Serialization;\nvar deserializer = new DeserializerBuilder().Build();\nusing (var file = File.OpenText(\"_config.yml\"))\n{\n    return deserializer.Deserialize&lt;T&gt;(file);\n}\n<\/code><\/pre>\n<p><strong>js-yaml<\/strong><br \/><a href=\"https:\/\/github.com\/nodeca\/js-yaml\" class=\"github\"><img decoding=\"async\" src=\"https:\/\/img.shields.io\/github\/stars\/nodeca\/js-yaml.svg?style=social&amp;label=Star\" \/><\/a><a href=\"https:\/\/github.com\/nodeca\/js-yaml\">nodeca\/js-yaml<\/a>: For Node, there is js-yaml<\/p>\n<pre><code class=\"language-js\">npm install js-yaml\n\nyaml = require('js-yaml');\nfs = require('fs');\ntry {\n  var doc = yaml.safeLoad(fs.readFileSync('_config.yml', 'utf8'));\n} catch (e) {\n}\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Everyone happy when the downfall Xml was a fact with the widespread use of Json. Less tags, more data. What\u2019s there not to like. It\u2019s also just so much easier for a human to read.<\/p>\n<p>If it wasn\u2019t so straightforward to parse JSON in the omnipresent JavaScript, Yaml might have had a good chance to take over the world being <strong>the<\/strong> most readable data serialization language.<\/p>\n","protected":false},"author":1,"featured_media":2102,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"inline_featured_image":false,"footnotes":""},"categories":[19],"tags":[6],"class_list":["post-1645","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-productivity","tag-tutorial"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Yaml tutorial - Itenium<\/title>\n<meta name=\"robots\" content=\"noindex, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Yaml tutorial - Itenium\" \/>\n<meta property=\"og:description\" content=\"Everyone happy when the downfall Xml was a fact with the widespread use of Json. Less tags, more data. What\u2019s there not to like. It\u2019s also just so much easier for a human to read.If it wasn\u2019t so straightforward to parse JSON in the omnipresent JavaScript, Yaml might have had a good chance to take over the world being the most readable data serialization language.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Itenium\" \/>\n<meta property=\"article:published_time\" content=\"2018-08-13T16:00:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-28T12:31:46+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png\" \/>\n\t<meta property=\"og:image:width\" content=\"360\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Usdevelop\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Usdevelop\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/\",\"url\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/\",\"name\":\"Yaml tutorial - Itenium\",\"isPartOf\":{\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png\",\"datePublished\":\"2018-08-13T16:00:00+00:00\",\"dateModified\":\"2025-11-28T12:31:46+00:00\",\"author\":{\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/6ab401ce01e858184ee4a8667fe0f022\"},\"breadcrumb\":{\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage\",\"url\":\"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png\",\"contentUrl\":\"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png\",\"width\":360,\"height\":300},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/demo.sidekick.be\/itenium\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Yaml tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/#website\",\"url\":\"https:\/\/demo.sidekick.be\/itenium\/\",\"name\":\"Itenium\",\"description\":\"We build software. We build careers.\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/demo.sidekick.be\/itenium\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/6ab401ce01e858184ee4a8667fe0f022\",\"name\":\"Usdevelop\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/cc8cf9b9e9d5bbe7e8d247907cc9ac8457bbfa2854b52eaddf6529adfe88ceab?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/cc8cf9b9e9d5bbe7e8d247907cc9ac8457bbfa2854b52eaddf6529adfe88ceab?s=96&d=mm&r=g\",\"caption\":\"Usdevelop\"},\"sameAs\":[\"https:\/\/demo.sidekick.be\/itenium\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Yaml tutorial - Itenium","robots":{"index":"noindex","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_title":"Yaml tutorial - Itenium","og_description":"Everyone happy when the downfall Xml was a fact with the widespread use of Json. Less tags, more data. What\u2019s there not to like. It\u2019s also just so much easier for a human to read.If it wasn\u2019t so straightforward to parse JSON in the omnipresent JavaScript, Yaml might have had a good chance to take over the world being the most readable data serialization language.","og_url":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/","og_site_name":"Itenium","article_published_time":"2018-08-13T16:00:00+00:00","article_modified_time":"2025-11-28T12:31:46+00:00","og_image":[{"width":360,"height":300,"url":"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png","type":"image\/png"}],"author":"Usdevelop","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Usdevelop","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/","url":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/","name":"Yaml tutorial - Itenium","isPartOf":{"@id":"https:\/\/demo.sidekick.be\/itenium\/#website"},"primaryImageOfPage":{"@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png","datePublished":"2018-08-13T16:00:00+00:00","dateModified":"2025-11-28T12:31:46+00:00","author":{"@id":"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/6ab401ce01e858184ee4a8667fe0f022"},"breadcrumb":{"@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#primaryimage","url":"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png","contentUrl":"https:\/\/demo.sidekick.be\/itenium\/wp-content\/uploads\/2025\/11\/yaml.png","width":360,"height":300},{"@type":"BreadcrumbList","@id":"https:\/\/demo.sidekick.be\/itenium\/blog\/productivity\/yaml-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/demo.sidekick.be\/itenium\/"},{"@type":"ListItem","position":2,"name":"Yaml tutorial"}]},{"@type":"WebSite","@id":"https:\/\/demo.sidekick.be\/itenium\/#website","url":"https:\/\/demo.sidekick.be\/itenium\/","name":"Itenium","description":"We build software. We build careers.","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/demo.sidekick.be\/itenium\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/6ab401ce01e858184ee4a8667fe0f022","name":"Usdevelop","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/demo.sidekick.be\/itenium\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/cc8cf9b9e9d5bbe7e8d247907cc9ac8457bbfa2854b52eaddf6529adfe88ceab?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/cc8cf9b9e9d5bbe7e8d247907cc9ac8457bbfa2854b52eaddf6529adfe88ceab?s=96&d=mm&r=g","caption":"Usdevelop"},"sameAs":["https:\/\/demo.sidekick.be\/itenium"]}]}},"_links":{"self":[{"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/posts\/1645","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/comments?post=1645"}],"version-history":[{"count":3,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/posts\/1645\/revisions"}],"predecessor-version":[{"id":2309,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/posts\/1645\/revisions\/2309"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/media\/2102"}],"wp:attachment":[{"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/media?parent=1645"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/categories?post=1645"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/demo.sidekick.be\/itenium\/wp-json\/wp\/v2\/tags?post=1645"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}