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
2553
votes
9 answers

How do I break a string in YAML over multiple lines?

I have a very long string: Key: 'this is my very very very very very very long string' I would like to express it over multiple shorter lines, e.g., Key: 'this is my very very very ' + 'long string' I would like to use quotes as above, so…
jjkparker
  • 27,597
  • 6
  • 28
  • 29
1481
votes
11 answers

How do you do block comments in YAML?

How do I comment a block of lines in YAML?
Thierry Lam
  • 45,304
  • 42
  • 117
  • 144
1044
votes
10 answers

How can I parse a YAML file in Python

How can I parse a YAML file in Python?
Szymon Lipiński
  • 27,098
  • 17
  • 75
  • 77
928
votes
15 answers

What is the difference between YAML and JSON?

What are the differences between YAML and JSON, specifically considering the following things? Performance (encode/decode time) Memory consumption Expression clarity Library availability, ease of use (I prefer C) I was planning to use one of these…
pierrotlefou
  • 39,805
  • 37
  • 135
  • 175
744
votes
8 answers

YAML: Do I need quotes for strings in YAML?

I am trying to write a YAML dictionary for internationalisation of a Rails project. I am a little confused though, as in some files I see strings in double-quotes and in some without. A few points to consider: example 1 - all strings use double…
Alexander Popov
  • 23,073
  • 19
  • 91
  • 130
515
votes
5 answers

Is it .yaml or .yml?

According to yaml.org, the official file extension is .yaml. Quote: Is there an official extension for YAML files? Please use ".yaml" when possible. However there seems to be a disagreement on the internet on which extension to use. If you look…
spuder
  • 17,437
  • 19
  • 87
  • 153
464
votes
4 answers

What's the best practice using a settings file in Python?

I have a command line script that I run with a lot of arguments. I have now come to a point where I have too many arguments, and I want to have some arguments in dictionary form too. So in order to simplify things I would like to run the script with…
c00kiemonster
  • 22,241
  • 34
  • 95
  • 133
462
votes
12 answers

How do I install the yaml package for Python?

I have a Python program that uses YAML. I attempted to install it on a new server using pip install yaml and it returns the following: $ sudo pip install yaml Downloading/unpacking yaml Could not find any downloads that satisfy the requirement…
harperville
  • 6,921
  • 8
  • 28
  • 36
450
votes
17 answers

How can I include a YAML file inside another?

So I have two YAML files, "A" and "B" and I want the contents of A to be inserted inside B, either spliced into the existing data structure, like an array, or as a child of an element, like the value for a certain hash key. Is this possible at all?…
kch
  • 77,385
  • 46
  • 136
  • 148
395
votes
8 answers

How to escape indicator characters (colon and hyphen) in YAML

In a config file, I have a key to which I wish to assign a URL. The problem is that YAML interprets : and - characters as either creating mappings or lists, so it has a problem with the line url: http://www.some-site.example/ (both because of the…
danieltahara
  • 4,743
  • 3
  • 18
  • 20
337
votes
3 answers

YAML equivalent of array of objects in JSON

I have a JSON array of objects that I'm trying to convert to YAML. {"AAPL": [ { "shares": -75.088, "date": "11/27/2015" }, { "shares": 75.088, "date": "11/26/2015" }, ]} Is there an equivalent representation in YAML that…
wegry
  • 7,046
  • 6
  • 39
  • 59
336
votes
2 answers

why --- (3 dashes/hyphen) in yaml file?

So I just started using YAML file instead of application.properties as it is more readable. I see in YAML files they start with ---. I googled and found the below explanation. YAML uses three dashes (“---”) to separate directives from document …
Andy
  • 5,433
  • 6
  • 31
  • 38
336
votes
24 answers

How can I parse a YAML file from a Linux shell script?

I wish to provide a structured configuration file which is as easy as possible for a non-technical user to edit (unfortunately it has to be a file) and so I wanted to use YAML. I can't find any way of parsing this from a Unix shell script however.
yazz.com
  • 57,320
  • 66
  • 234
  • 385
315
votes
8 answers

YAML current date in rmarkdown

I'm wondering if there's a trick to put the current date in the YAML front-matter of a .rmd document to be processed by knitr and the rmarkdown package. I used to have the following line at the top of my wiki pages, _baptiste, `r…
baptiste
  • 75,767
  • 19
  • 198
  • 294
308
votes
16 answers

Setting active profile and config location from command line in Spring Boot

I have a Spring Boot application. I have three profiles in my application-> development, staging and production. So I have 3 files application-development.yml application-staging.yml application-production.yml My application.yml resides inside…
Vinod Mohanan
  • 3,729
  • 2
  • 17
  • 25
1
2 3
99 100