YAML每个缩进多少个空格

YAML每个缩进多少个空格

本文介绍了YAML每个缩进多少个空格?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果在 YAML 中每个缩进级别使用一个空格,两个或四个空格,有什么区别吗?

Is there any difference if i use one space, two or four spaces per indent level in YAML?

每种结构类型的空间编号是否有特定规则?

Are there any specific rules for space numbers per Structure type??

例如 4 个用于嵌套地图的空间,每个列表项 1 个空间等?

For example 4 spaces for nesting maps , 1 space per list item etc??

我正在为弹性beantalk .ebextensions写一个yaml配置文件,我很难正确地构建它.尽管我在 YAML验证程序中具有有效的Yaml,但是弹性beantalk似乎理解了另一种结构.

I am writing a yaml configuration file for elastic beanstalk .ebextensions and i am having really hard time constructing this correctly. Although i have valid yaml in YAML Validator elastic beanstalk seems to understand a different structure.

推荐答案

YAML中没有要求缩进任何具体数量的空格.也没有要求保持一致.因此,例如,这是有效的YAML:

There is no requirement in YAML to indent any concrete number of spaces. There is also no requirement to be consistent. So for example, this is valid YAML:

a:
 b:
     - c
     -  d
     - e
f:
    "ghi"

一些规则可能很有趣:

  • 流内容(即以 { [开头的所有内容)可以跨越多行,但必须缩进至少与周围当前块级别一样多的空格.
  • 阻止列表项目可以(但不必)与周围的块级别具有相同的缩进,因为-被认为是缩进的一部分:
  • Flow content (i.e. everything that starts with { or [) can span multiple lines, but must be indented at least as many spaces as the surrounding current block level.
  • Block list items can (but don't need to) have the same indentation as the surrounding block level because - is considered part of the indentation:
a:    # top-level key
- b   # value of that key, which is a list
- c
c:    # next top-level key
 d    # non-list value which must be more indented

这篇关于YAML每个缩进多少个空格?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-18 09:19