Zum Hauptinhalt springen
IT Security NachrichtenUnderstanding Golden Ticket Attacks: Detection & Fix(03.10.2026 um 06:19 Uhr)
••••
Podcasts & Audio BriefingsMini-PCs im Test: stark wie nie, aber viele sind teuer | c’t uplink(03.10.2026 um 06:30 Uhr)
•
AI & KI NachrichtenStudents turn to lawyers to fight AI misconduct accusations(03.10.2026 um 06:00 Uhr)
•
AI & KI NachrichtenThe coming futures market in AI compute(03.10.2026 um 06:00 Uhr)
•••
Sicherheitslücken (CVE)CVE-2025-31995 | HCL MaxAI Workbench input validation (KB0124425)(03.10.2026 um 05:32 Uhr)
•
IT Security NachrichtenUnderstanding Golden Ticket Attacks: Detection & Fix(03.10.2026 um 06:19 Uhr)
••••
Podcasts & Audio BriefingsMini-PCs im Test: stark wie nie, aber viele sind teuer | c’t uplink(03.10.2026 um 06:30 Uhr)
•
AI & KI NachrichtenStudents turn to lawyers to fight AI misconduct accusations(03.10.2026 um 06:00 Uhr)
•
AI & KI NachrichtenThe coming futures market in AI compute(03.10.2026 um 06:00 Uhr)
•••
Sicherheitslücken (CVE)CVE-2025-31995 | HCL MaxAI Workbench input validation (KB0124425)(03.10.2026 um 05:32 Uhr)
•
Intelligence View
⚡ tsecurity.de Intelligence

HPR3228: YAML basics

YAML has two data elements that serve as building blocks for complex data structures: sequences and mappings. Sequence This is a sequence: --- - Emperor -…

Beitrag
0
Seite
0
↗ Quelle (hackerpublicradio.org)
Social ReaktionenReagiere als Erste:r — dein Feedback zählt!

YAML has two data elements that serve as building blocks for complex data structures: sequences and mappings.



Sequence



This is a sequence:




---
- Emperor
- Gentoo
- Little Blue


Mapping




This is a mapping:




---
Penguin: Emperor



In this case, Penguin is a key and Emperor is a value. This is often called a "key and value pair", but in YAML it's just called a mapping.



Combining data blocks




You can embed these data types into one another. Here is a mapping that has a sequence as its value:




---
Penguin:
- Emperor
- Gentoo
- Little Blue



Here is a sequence of mappings:




---
- Penguin: Emperor
- Penguin: Gentoo
- Penguin: Little Blue


yamllint



Use yamllint to detect errors in your YAML. To install:





$ pip install yamllint


Run it:





$ yamllint good.yaml
$ yamllint bad.yaml
bad.yaml
1:1 warning missing document start "---" (document-start)
4:14 error no new line character at the end of file (new-line-at-end-of-file)


yaml2json




Sometimes it's useful to convert your YAML to JSON so you can view the data structure in a different way. There are probably dozens of YAML-to-JSON converters out there, but here's the one I use: http://gitlab.com/slackermedia/yaml2json.git




Run it:




$ cat example.yaml
---
penguins:
- Gentoo
- Little Blue
- Rockhopper
dragons:
- black
- white
- red
$ ~/bin/yaml2json.py example.yaml
{"penguins": ["Gentoo", "Little Blue", "Rockhopper"], "dragons": ["black", "white", "red"]}


YAML police



There are no YAML police. As long as yamllint finds no errors, your YAML is valid and can be parsed by any one of the dozens of YAML libraries out there. However, these YAML libraries aren't magical, so you must understand the internal logic of your own YAML data. Keep that in mind when devising a scheme for the data you're recording.



YAML is a great method for creating configuration files, or storing simple data structures, and it's essential for Ansible playbooks.




Enjoy!

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten HPR3228: YAML basics

Thematisch verwandte Begriffe: HPR3228, YAML, basics · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
Nächster Beitrag