Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Have any simplified YAML formats become widespread?

I love YAML.

Wait, let me back up. I love YAML that looks like this, even more than JSON:

Projects:
  C/C++ Libraries:
  - libyaml       # "C" Fast YAML 1.1
  - Syck          # (dated) "C" YAML 1.0
  - yaml-cpp      # C++ YAML 1.2 implementation
  Ruby:
  - psych         # libyaml wrapper (in Ruby core for 1.9.2)
  - RbYaml        # YAML 1.1 (PyYaml Port)
  - yaml4r        # YAML 1.0, standard library syck binding
  ...

I love YAML anchors and references too, and sometimes wish JSON had them.

But I hope most of us can agree that the following is not so human readable (I know this example is didactic, but the point is since it is valid YAML, people you're collaborating with could pollute your data with such features):

!!map {
  ? !!str "sequence"
  : !!seq [ !!str "one", !!str "two" ],
  ? !!str "mapping"
  : !!map {
    ? !!str "sky" : !!str "blue",
    ? !!str "sea" : !!str "green",
  },
}

So I'm disappointed I can't find any widespread coups to standardize a simplified subset of YAML, at least with a cursory Google search.

Does anyone know of one?

like image 893
Andy Avatar asked May 02 '15 18:05

Andy


People also ask

Why is YAML so popular?

YAML is a popular programming language because it is human-readable and easy to understand. It can also be used in conjunction with other programming languages.

What is YAML file format?

YAML is a digestible data serialization language often used to create configuration files with any programming language. Designed for human interaction, YAML is a strict superset of JSON, another data serialization language.

Why do we need YAML file?

Definition. YAML is a human-readable data serialization standard that can be used in conjunction with all programming languages and is often used to write configuration files.

What is true about YAML?

YAML Ain't Markup Language is a data serialization language that matches user's expectations about data. It designed to be human friendly and works perfectly with other programming languages. It is useful to manage data and includes Unicode printable characters.


1 Answers

There are many such subsets. Almost every YAML library defines one implicitly by the format that results from round-tripping (loading YAML into internal data and serialising the data back to YAML).

You often can influence these subsets, but they tend to have useful defaults with block structure for larger collections and flow-style for smaller ones (each according to what the library developer considered readable).

IMO the way to deal with rogue editors is to round-trip the code through the yaml utility (of which I am the author) that comes with ruamel.yaml parser, and then use it. If you don't like the subset it forces on you, it is should be relatively easy to make changes to its serializer settings by experimenting. Such "normalisation" is IMO a must before storing/updating any YAML file in a revision control system.

like image 185
Anthon Avatar answered Sep 28 '22 18:09

Anthon