Stop 03 · Linux & Scripting BasicsTopics · 8/9

YAML & JSON Fundamentals

Part of the Cloud Computing Roadmap

In short

Kubernetes manifests, CI pipelines, CloudFormation, API responses: half your cloud life is reading YAML and JSON. One wrong space can break a deploy, so it's worth getting comfortable now.

The near-universal configuration formats across cloud tools — CloudFormation templates, Kubernetes manifests, and most API responses use one or both — understanding their syntax prevents a huge share of frustrating errors.

The blob character runs a finger down a lined reservation chart beside a train door.

Think of it like this

The reservation chart on the coach

The chart outside a train coach is neat rows: name, age, seat. Everyone, including the TT, reads it the same way. If one row slides sideways, people end up in the wrong berth. Config files work the same way.

Watch it happen

One config, as a tree

(document)
name: web
replicas: 3
ports: [list]
- 80
- 443
env: {map}
LOG_LEVEL: info

1/4Both YAML and JSON describe the same thing: a tree of keys, values, lists and nested maps.

The big ideas

What you need to know

JSON is strict

Double quotes on keys and strings, commas between items, no comments. Machines love it, which is why APIs return it.

YAML is indentation

Spaces define nesting. Never tabs. Two spaces per level is the usual habit.

Same data, two styles

Valid JSON is also valid YAML. Most tools accept both, and you can convert between them freely.

YAML has surprises

Older parsers read yes, no, on and off as true or false. Quote values like '08' or 'no' to keep them strings.

See it in code

Walk through the code

yaml
1# app.yaml2name: web3replicas: 34ports:5  - 806  - 4437env:8  LOG_LEVEL: info9  COUNTRY: "NO"        # quoted, or old parsers read it as false10# Same thing in JSON:11# {"name":"web","replicas":3,"ports":[80,443],12#  "env":{"LOG_LEVEL":"info","COUNTRY":"NO"}}

1/4Plain keys at the top level, no indentation.

Run it through a linter like yamllint, or paste it into any online YAML-to-JSON converter, before you deploy it.

Save yourself the pain

Common mistakes

Oops

Mixing tabs and spaces, or indenting one line by three spaces.

Do this instead

Set your editor to insert spaces and show whitespace. Keep every level at the same two-space step.

Oops

Adding a trailing comma or comment in JSON.

Do this instead

JSON allows neither. Remove the last comma, and keep notes in a README instead.

Your mission

Break it, then fix it

~15 min

Quick check

Why do YAML files often break after copy-pasting from a web page?

Go deeper

  1. 1Write a small YAML file and a small JSON file describing the same data, and compare readability.
  2. 2Learn common YAML pitfalls: inconsistent indentation, tabs vs spaces, and quoting rules.
  3. 3Practice parsing a JSON API response using a tool like jq.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge