2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

YAMLでネストした配列を作る

Last updated at Posted at 2018-07-03

YAML (ブロックスタイル)

なんだか奇妙なシンタックスに見えるが、空のハイフン行 - の後に、さらに配列記法を続ければ良い。

- 1   # 配列の1個目
- 2   # 配列の2個目
-     # 配列の3個目には別の配列をネスト
  - 3    # ネストした配列内の1個目
  - 4    # ネストした配列内の2個目
  -      # ネストした配列の3個目には、さらに新しい配列をネスト (以下略)
    - 5
    - 6

JSONでの解釈

[
  1, 
  2, 
  [
    3, 
    4, 
    [
      5, 
      6
    ]
  ]
]

YAML (フロースタイル)

結果は最初の例と同等。

[1,2, [3,4, [5,6]]]

YAML (ブロックスタイルとフロースタイルの併用)

結果は最初の例と同等。

- 1
- 2
- [3,4, [5,6]]

参考

チャットメンバー募集

何か質問、悩み事、相談などあればLINEオープンチャットもご利用ください。

Twitter

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?