Are simplified YAML formats expandable?

I like YAML.

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

  C/C++ Libraries:
  - libyaml       # "C" Fast YAML 1.1
  - Syck          # (dated) "C" YAML 1.0
  - yaml-cpp      # C++ YAML 1.2 implementation
  - 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 like YAML anchors and links too, and sometimes would like JSON to have them.

But I hope most of us would agree that the following is not that human-readable (I know this example is didactic, but the point is, this is really YAML, the people you collaborate with can pollute your data like this functions):

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


So I'm disappointed. I cannot find any large-scale coups to standardize a simplified subset of YAML, at least on a cursory Google search.

Does anyone know about this?


source to share

1 answer

There are many such subsets. Almost every YAML library uniquely defines the format that is the result of rounding (loading YAML into internal data and serializing the data back to YAML).

You can often influence these subsets, but they tend to have useful block-structured defaults for large collections and stream style for smaller ones (each according to what the library developer thought was readable).

IMO the way to deal with rogue editors is to combine the code with the utility yaml

(of which I am the author) that comes with ruamel.yaml and then use that. If you don't like the subset it imposes on you, it should be relatively easy to make changes to the serializer settings by experimenting. This kind of "normalization" is IMO before storing / updating any YAML file in source control.



All Articles