YAML. Complex Structure YAML. Complex Structure
Elementary
RU English

The 4th task in the series of missions about the YAML format will be devoted to a complex structure.

An array element can be another array.

- Alex
-
  - odessa
  - dnipro
- Li
[
  "Alex", 
  [
    "odessa", 
    "dnipro"
  ], 
  "Li"
]

A dictionary can also be an element of an array.

- 67
-
  name: Irv
  game: Mario
-
- 56

[
  67, 
  {
    "game": "Mario", 
    "name": "Irv"
...

A dictionary element can be another dictionary.

name: Alex
study:
  type: school
  number: 78
age: 14
{
  "age": 14, 
  "study": {
    "type": "school", 
    "number": 78
  }, 
  "name": "Alex"
}

An array can also be an element of a dictionary.

name: Alex
study:
  - 89
  - 89
  - "Hell"
age: 14
{
  "age": 14, 
  "study": [
    89, 
    89, 
    "Hell"
  ], 
  "name": "Alex"
}

And, of course, data can have more than one nesting level.

name: Alex
study:
  -
    type: school
    num: 89
  -
    type: school
    num: 12
age: 14
{
  "age": 14, 
  "study": [
    {
      "num": 89, 
      "type": "school"
    }, 
    {
      "num": 12, 
      "type": "school"
    }
  ], 
  "name": "Alex"
}

Format string.

An object.

yaml('- Alex\n'
 '-\n'
 '  - odessa\n'
 '  - dnipro\n'
 '- Li') == ['Alex', ['odessa', 'dnipro'], 'Li']
yaml('- 67\n'
 '-\n'
 '  name: Irv\n'
 '  game: Mario\n'
 '-\n'
 '- 56') == [67,
 {'game': 'Mario', 'name': 'Irv'},
 None,
 56]

You should be an authorized user in order to see the full description and start solving this mission.