YAML. Complex Structure YAML. Complex Structure
Moderate
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"
  }, 
  null, 
  56
]

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"
}

Input: Format string.

Output: An object.

Example:

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]

Precondition: The YAML 1.2 standard is being used.

Settings
Code:
CheckiO Extensions

CheckiO Extensions allow you to use local files to solve missions. More info in a blog post.

In order to install CheckiO client you'll need installed Python (version at least 3.8)

Install CheckiO Client first:

pip3 install checkio_client

Configure your tool

checkio --domain=py config --key=

Sync solutions into your local folder

checkio sync

(in beta testing) Launch local server so your browser can use it and sync solution between local file end extension on the fly. (doesn't work for safari)

checkio serv -d

Alternatevly, you can install Chrome extension or FF addon

checkio install-plugin
checkio install-plugin --ff
checkio install-plugin --chromium

Read more here about other functionality that the checkio client provides. Feel free to submit an issue in case of any difficulties.

×
 
 
<< <
> >>
exec

Whats Next?

Free accounts will see Best CheckiO solutions with some delay.
Best Solutions will be opened in
Become Awesome and Don't wait
The next stage is ""
Will be activated in
View More Solutions Random Review Solutions Share your own solution
Go to the next mission Back to the list of missions Back to the map