๐Ÿ“– 2 min read (~ 300 words).

More

KYAML: simplified YAML

KYAML is a subset of YAML that Kubernetes defined to avoid YAML’s traps: whitespace that changes the meaning, and plain text that turns into another type. It writes every collection in flow style, with braces and brackets, and every string value double-quoted.

---
{
  apiVersion: "v1",
  kind: "Pod",
  metadata: {
    name: "my-pod",
    labels: {
      app: "demo"
    },
  },
  spec: {
    containers: [{
      name: "nginx",
      image: "nginx:1.20"
    }]
  }
}

Because KYAML is YAML, any YAML parser reads it. This is the example of the KYAML reference, as go-yaml reads it:

{
  "apiVersion": "v1",
  "kind": "Pod",
  "metadata": {
    "name": "my-pod",
    "labels": {
      "app": "demo"
    }
  },
  "spec": {
    "containers": [
      {
        "name": "nginx",
        "image": "nginx:1.20"
      }
    ]
  }
}

kubectl get -o kyaml writes it. The format came with KEP-5295, as alpha in Kubernetes 1.34.

YAMLStar, YAMLScript

Ingy dรถt Net, one of YAML’s authors, has two projects built on the YAML 1.2 specification.

YAMLStar is a YAML loader and dumper for many languages, built on the YAML Reference Parser. It aims at full YAML 1.2 compliance, and it evaluates nothing: it reads data.

YAMLScript, or YS, is a YAML loader that is also a functional programming language. A plain YAML file loads as data. A file tagged !ys-0 may hold code as well, which YS compiles to Clojure and runs. YAMLStar derives from YAMLScript, without the code.

Both are MIT-licensed and offer bindings for some thirty languages, Go among them.