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
118
votes
2 answers

Reuse a block of code in YAML

I want to reuse a hash in YAML: Defaults: &defaults Company: Foo Item: 123 Computer: *defaults Price: 3000 However, this generates an error. Is the only way to anchor each field value separately like this? Defaults: Company: &company Foo …
ajsie
  • 77,632
  • 106
  • 276
  • 381
114
votes
7 answers

Wrong indentation when editing Yaml in Vim

Vim does not seem to correctly react at a dash symbol in YAML files therefore breaking the format. For example I have a block which should look like this: handlers: - name: restart exim4 service: name=exim4 state=restarted When…
Glueon
  • 3,727
  • 4
  • 23
  • 32
108
votes
7 answers

PHP YAML Parsers

Does anyone know of a good YAML Parser for PHP? If so, what are the pros and cons of this library?
sgibbons
  • 3,620
  • 11
  • 36
  • 31
102
votes
6 answers

YAML Schema Validation?

Is there a schema validation language for YAML? I've googled but couldn't find anything useful. Something like XSD format, using the language itself to describe the schema, would be the best choice in my case.
Klaim
  • 67,274
  • 36
  • 133
  • 188
102
votes
9 answers

Can PyYAML dump dict items in non-alphabetical order?

I'm using yaml.dump to output a dict. It prints out each item in alphabetical order based on the key. >>> d = {"z":0,"y":0,"x":0} >>> yaml.dump( d, default_flow_style=False ) 'x: 0\ny: 0\nz: 0\n' Is there a way to control the order of the…
mwcz
  • 8,949
  • 10
  • 42
  • 63
101
votes
9 answers

List of Language Codes in YAML or JSON?

Is there a list of language codes in YAML or JSON somewhere out there? Another format is fine, I can convert it if necessary.
RyanScottLewis
  • 13,396
  • 16
  • 56
  • 84
100
votes
6 answers

Use YAML with variables

Are variables within YAML files possible? For example: theme: name: default css_path: compiled/themes/$theme.name layout_path: themes/$theme.name In this example, how can theme: name: default be used in other settings? What is the syntax?
brewster
  • 4,342
  • 6
  • 45
  • 67
97
votes
3 answers

How to make a list of associative array in yaml

I'm trying to store some configuration variables in yaml represented as an associative array aka dictionary. Here is how I did: content_prices: …
Antzi
  • 12,831
  • 7
  • 48
  • 74
96
votes
6 answers

Correct MySQL configuration for Ruby on Rails Database.yml file

I have this configuration: development: adapter: mysql2 encoding: utf8 database: my_db_name username: root password: my_password host: mysql://127.0.0.1:3306 And I am getting this error: Unknown MySQL server host…
GeekedOut
  • 16,905
  • 37
  • 107
  • 185
95
votes
2 answers

Parsing a YAML file in Python, and accessing the data?

I am new to YAML and have been searching for ways to parse a YAML file and use/access the data from the parsed YAML. I have come across explanations on how to parse the YAML file, for example, the PyYAML tutorial, "How can I parse a YAML file in…
9monkeys
  • 1,754
  • 1
  • 14
  • 13
95
votes
1 answer

How to specify wildcard artifacts subdirectories in .gitlab-ci.yml?

I'm using GitLab CI to build a C# solution and try to pass some build artifacts from one build stage to another. The problem is, that the artifacts are not located in a single directory but in different subdirectories, which however all have the…
swalex
  • 3,885
  • 3
  • 28
  • 33
95
votes
10 answers

How to access an application parameters from a service?

From my controllers, I access the application parameters (those in /app/config) with $this->container->getParameter('my_param') But I don't know how to access it from a service (I imagine my service class is not supposed to extend…
Pierre de LESPINAY
  • 44,700
  • 57
  • 210
  • 307
94
votes
2 answers

Building an array of dictionary items in YAML?

Basically trying to something in yaml that could be done using this json: { models: [ { model: "a" type: "x" #bunch of properties... }, { model: "b" type: "y" #bunch of properties... } ] } So far this is what I…
sadaf2605
  • 7,332
  • 8
  • 60
  • 103
93
votes
4 answers

Use placeholders in YAML

Is there a way to use placeholders in YAML like this: foo: &FOO <>: type: number default: <> bar: - *FOO propname: "some_prop" default: "some default"
92
votes
5 answers

Is there a way to alias/anchor an array in YAML?

I'm using Jammit to package assets up for a Rails application and I have a few asset files that I'd like to be included in each of a few groups. For example, I'd like Sammy and its plugins to be in both my mobile and screen JS packages. I've tried…
James A. Rosen
  • 64,193
  • 61
  • 179
  • 261