Help us understand the problem. What is going on with this article?

YAML to JSON

tl; dr

  • jsonは読めるけど、yamlはまだあまり読めない人が読めるようになる
  • vs codeユーザ向け

やり方

vscodeに以下をインストールします

では、早速適当なyamlファイルを変換してみましょう
(kubeのdeploymentファイルです)

  • 対象のyamlファイルを開いた状態で
  • shift + command + P を押す
  • 「YAML to JSON:Convert selection or document」と入力

すると以下のようにjsonに変換できます。
jsonが読めて、yamlはまだ苦手という方はこちらを活用してみるのもいいかもしれません。

before

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.14.2
        ports:
        - containerPort: 80

after

{
  "apiVersion": "apps/v1",
  "kind": "Deployment",
  "metadata": {
    "name": "nginx-deployment",
    "labels": {
      "app": "nginx"
    }
  },
  "spec": {
    "replicas": 3,
    "selector": {
      "matchLabels": {
        "app": "nginx"
      }
    },
    "template": {
      "metadata": {
        "labels": {
          "app": "nginx"
        }
      },
      "spec": {
        "containers": [
          {
            "name": "nginx",
            "image": "nginx:1.14.2",
            "ports": [
              {
                "containerPort": 80
              }
            ]
          }
        ]
      }
    }
  }
}
lughshot
サイバーエージェントでエンジニアをやってます。 主に、サーバサイドとインフラをやってます。最近は機械学習などにも興味があります。
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした