YAML序列样式 YAML 块样式 YAML 流映射 YAML序列样式 要理解序列样式,理解集合很重要。集合和序列样式的概念并行工作。YAML中的集合以适当的序列样式表示。如果要引用正确的标签排序,请始终参考集合。YAML中的集合由数组中表示的从零开始的连续整数编制索引。序列样式的重点始于集合。 例 让我们将宇宙中行星的数量视为可以作为集合创建的序列。以下代码显示如何表示Universe中行星的序列样式 # Ordered sequence of nodes in YAML STRUCTURE Block style: !!seq - Mercury # Rotates - no light/dark sides. - Venus # Deadliest. Aptly named. - Earth # Mostly dirt. - Mars # Seems empty. - Jupiter # The king. - Saturn # Pretty. - Uranus # Where the sun hardly shines. - Neptune # Boring. No rings. - Pluto # You call this a planet? Flow style: !!seq [ Mercury, Venus, Earth, Mars, # Rocks Jupiter, Saturn, Uranus, Neptune, # Gas Pluto ] # Overrated 然后,您可以看到JSON格式的有序序列的以下输出 { "Flow style": [ "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" ], "Block style": [ "Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto" ] } YAML 块样式 YAML 流映射