YAML Key Spaces

Is there a proper way to use spaces in YAML keys? how

a test: "hello world!" 

or

 "a test": "hello world!" 

or is it just a bad idea and you need to use

 a_test: "hello world!" 

They all seem valid in yaml-Linter, but I have not found any examples on the Internet using spaces in the key.

+5
source share
1 answer

One thing is that which is permitted, and the other is that which is read by man.

Spaces are allowed in keys in accordance with the specification, and for those who do not need quotes (double or single, each with their own use). This is just a scalar string containing a space.

As for human readability, I tend to think of a and test in a test as non-mutually related. This, of course, is due to what I'm used to, and that, for example, variables in most programming languages ​​cannot have spaces (although my one of my first languages, Algol 68, allowed this). For readability, I would suggest using a_test through "a test" (or 'a test' ), but others may have different settings.

+12
source

Source: https://habr.com/ru/post/1260824/


All Articles