English 中文(简体)
YAML – Block Sequences
  • 时间:2024-12-27

YAML - Block Sequences


Previous Page Next Page  

The block sequences of YAML represent a series of nodes. Each item is denoted by a leading “-“ indicator. Note that the “-“ indicator in YAML should be separated from the node with a white space.

The basic representation of block sequence is given below −

block sequence:
··- one↓
  - two : three↓

Example

Observe the following examples for a better understanding of block sequences.

Example 1

port: &ports
  adapter:  postgres
  host:     localhost

development:
  database: myapp_development
  <<: *ports

The output of block sequences in JSON format is given below −

{
   "port": {
      "adapter": "postgres",
      "host": "localhost"
   },
   "development": {
      "database": "myapp_development",
      "adapter": "postgres",
      "host": "localhost"
   }
}
Advertisements