I'm no YAML zealot though, I do use JSON most of the time, but in the past couple years I've started writing most of my config files in YAML where I have the opportunity.
e.g.
name: user
plural: users
label: User
...
primary_key: uid
display_key: full_name
unique_keys:
- username
- uid
client:
storage:
type: IndexedDB
...
actions:
create:
label: Save
permission: create_user
...
server:
storage:
type: mysql
...
api:
create_user:
url: /users
method: post
fields:
username:
name: username
label: Username
type: string
length: 20
required: true
editable: falseSo is this the equivalent of multiple JSON documents? I'm looking at:
http://yaml.org/spec/1.1/#id857577 and http://yaml.org/spec/1.1/#stream/information%20model
I'm actually having a hard time, even with some google-fu, finding information about how this might be used. YAML->json parsers have failed to handle docs with a '...' separating parts of a document so far. Would this triple-dot structure be used to create multiple JS objects? How would I find more information about how this might be used in practice?
I have a feeling this would be easier to figure out if I just went and played around with it in practice, but it also seems like something that could be documented in more beginner-friendly terms.
I'll probably be kicking myself once I figure it out, but I also only have a cursory understanding of how streams work. Maybe this is an opportunity to fix that. Once I figure it out, I'll respond to this if nobody else has.
However, since you asked:
In a YAML document, there is an implicit top-level object, either a hash/dict/associative array or a list/array depending on your formatting.
The '...' separates streams, or top-level objects, within a single file or IO stream.
YAML parsers generally stop when they hit the separator, even in languages that can do multiple assignment. If your IO stream behaves like a file handle, you can read it repeatedly into different variables until EOF.
Multiple streams in a YAML document are fairly uncommon. I think most people don't know they exist, but I appreciate the flexibility and use it whenever it makes sense.
It just seems like YAML is making things more implicit. I like explicitness. Not against YAML, but it's no holy grail in my mind.
I'm more experienced with JSON than YAML and could be swayed on this, but so far I'm not. They seem like two roughly equal ways to do the same thing.
This seems oddly similar to the nit-picky problems people have when learning Python from a C-like background and being annoyed that semicolons and flexible indentation aren't the norm. When I spend months working on JS code, looking at Python slightly annoys me, and vice-versa, so I think I get it. I just don't think it's an important, game-changing thing.
I'll be learning about Ansible soon, so I'll have to also learn YAML syntax. I guess I'll have a more educated view once I've gotten deep into that.