Questions tagged [yaml]

Use this tag for questions about the YAML data serialization format only, not for questions about programs (or examples) that happen to have their configuration in a YAML format. Questions about the CSS framework also called YAML should be tagged [yaml-css] instead.

From the Wikipedia article about YAML:

YAML (/ˈjæməl/, rhymes with camel) is a human-readable data serialization language that takes concepts from programming languages such as C, Perl, and Python, and ideas from XML and the data format of electronic mail (RFC 2822). YAML was first proposed by Clark Evans in 2001, who designed it together with Ingy döt Net and Oren Ben-Kiki. It is available for several programming languages.

YAML is a recursive acronym for "YAML Ain't Markup Language". Early in its development, YAML was said to mean "Yet Another Markup Language", but it was then reinterpreted (backronyming the original acronym) to distinguish its purpose as data-oriented, rather than document markup.

Features:

  • Its familiar indented outline and lean appearance make it especially suited for tasks where humans are likely to view or edit data structures, such as configuration files, dumping during debugging, and document headers.
  • Although well-suited for hierarchical data representation, it also has a compact syntax for relational data as well.
  • A major part of its accessibility comes from eschewing the use of enclosures like quotation marks, brackets, braces, and open/close-tags, which can be hard for the human eye to balance in nested hierarchies.

See also

Related tags

15259 questions
161
votes
2 answers

Syntax for empty dictionary in YAML

How do I denote an empty dictionary in YAML? I.e. it should be semantically equivalent to the empty json-object {}.
Betamos
  • 26,448
  • 9
  • 23
  • 28
160
votes
9 answers

YAML media type?

What is the most appropriate media type (formally MIME type) to use when sending data structured with YAML over HTTP and why? There is no registered application type or text type that I can see. Example: > GET /example.yaml < Content-Type: ???? < <…
Jon Cram
  • 16,609
  • 24
  • 76
  • 107
151
votes
5 answers

Runtime error: assignment to entry in nil map

I am trying to generate a map and then convert that to a yaml file like this: uid : kasi: cn: Chaithra street: fkmp nandan: cn: Chaithra street: fkmp remya: cn: Chaithra street:…
Kasinath Kottukkal
  • 2,471
  • 4
  • 22
  • 28
151
votes
3 answers

What is the canonical YAML naming style

I am designing a new YAML file, and I want to use the most standard style of naming. Which is it? Hyphenated? - job-name: ... lower_case_with_underscores? - job_name: ... CamelCase? - jobName: ...
John McGehee
  • 9,117
  • 9
  • 42
  • 50
150
votes
8 answers

In Python, how can you load YAML mappings as OrderedDicts?

I'd like to get PyYAML's loader to load mappings (and ordered mappings) into the Python 2.7+ OrderedDict type, instead of the vanilla dict and the list of pairs it currently uses. What's the best way to do that?
Eric Naeseth
  • 2,293
  • 2
  • 19
  • 18
147
votes
7 answers

How do I validate my YAML file from command line?

I am having issues pulling from a YAML config file: Fatal error: while parsing a block mapping; expected , but found block entry While there are plenty of online YAML validators, which I have tried and have helped, I'd like to validate…
user375566
139
votes
5 answers

Multiline YAML string for GitLab CI (.gitlab-ci.yml)

I'm trying to write a gitlab-ci.yml file which uses a multi-line string for the command. However, it seems like it is not being parsed. I've tried both the - | and - > with identical results. stages: - mystage Build: stage: mystage script: …
samanime
  • 25,408
  • 15
  • 90
  • 139
135
votes
2 answers

What is the << (double left arrow) syntax in YAML called, and where's it specified?

The <<: operator in YAML is usable to import the contents of one mapping into another, similarly to the ** double-splat operator in Python or ... object destructuring operator in JavaScript. For example, foo: a: b <<: c: d e: f is…
Mark Amery
  • 143,130
  • 81
  • 406
  • 459
131
votes
11 answers

Error parsing yaml file: mapping values are not allowed here

I want to upload an app to Google App Engine: I get this Error parsing yaml file: mapping values are not allowed here in "/home/antonio/Desktop/ATI/climate-change/app.yaml", line 2, column 8 When running ./appcfg.py update…
andandandand
  • 21,946
  • 60
  • 170
  • 271
129
votes
5 answers

Is there YAML syntax for sharing part of a list or map?

So, I know I can do something like this: sitelist: &sites - www.foo.com - www.bar.com anotherlist: *sites And have sitelist and anotherlist both contain www.foo.com and www.bar.com. However, what I really want is for anotherlist to also…
Ben
  • 68,572
  • 20
  • 126
  • 174
125
votes
1 answer

Set default Timeout on Github action pipeline

Normally, my pipelines take 15 minutes to execute. Recently, for some strange reasons, some pipelines take between 45 minutes and 6 hours to fail. Is it possible to set a default timeout limit on GitHub Action's pipeline (for example, auto cancel…
Kevin ABRIOUX
  • 16,507
  • 12
  • 93
  • 99
125
votes
19 answers

How to set dynamic values with Kubernetes yaml file

For example, a deployment yaml file: apiVersion: extensions/v1beta1 kind: Deployment metadata: name: guestbook spec: replicas: 2 template: metadata: labels: app: guestbook spec: container: - name:…
online
  • 4,919
  • 10
  • 32
  • 47
125
votes
3 answers

Empty field in yaml

I want to leave a value in my .yaml field empty, because in another translation there has to be something but not in this one. Just leaving it empty prints out the path of the value (...title.3). title: 1: String 2: String2 3:
maidi
  • 3,219
  • 6
  • 27
  • 55
124
votes
4 answers

How to parse/read a YAML file into a Python object?

How to parse/read a YAML file into a Python object? For example, this YAML: Person: name: XYZ To this Python class: class Person(yaml.YAMLObject): yaml_tag = 'Person' def __init__(self, name): self.name = name I am using PyYAML by the…
Jamal Khan
  • 9,371
  • 6
  • 23
  • 23
121
votes
13 answers

Converting Swagger specification JSON to HTML documentation

For some REST APIs written in PHP, I was asked to create Swagger documentation, and since I was not aware of any easy way of annotating those existing APIs and create such a documentation, I used this editor to generate some for now. I saved the…
Salil
  • 1,739
  • 2
  • 15
  • 25