3 ms·
Something I've never liked about YAML, and I've not found a way around, is that you can't know if you have the entire file because there isn't an end marker. If
by onion2k 8y ago
Something I've never liked about YAML, and I've not found a way around, is that you can't know if you have the entire file because there isn't an end marker. If someone cut'n'pastes a block of YAML you don't know if they missed a bit off the end by mistake (unless you know the schema). That makes it harder to debug problems with YAML config.
- majewsky 8y agoYou could make a convention where the file has to end with a document separator, i.e. --- But depending on the exact setup and used YAML parser, this may be hard to enforce.
- jw1224 8y agoFrom the YAML spec[1]: > Three dots ( “...”) indicate the end of a document without starting a new one, for use in communication channels [1] https://yaml.org/spec/1.2/spec.html#id2760395 https://yaml.org/spec/1.2/spec.html#id2760395
- onion2k 8y agoThree dots indicates the end of a block, not a document. Look at Example 2.8 in your link. If the user sends; --- time: 20:03:20 player: Sammy Sosa action: strike (miss) ... .. you can't know if they actually meant to send .. --- time: 20:03:20 player: Sammy Sosa action: strike (miss) ... --- time: 20:03:47 player: Sammy Sosa action: grand slam ... Also, in my experience, which is mostly limited to Ansible config because I prefer JSON, I've never seen three dots in the wild. I don't think devops people like them.
- calibas 8y agoThey mark the end of a YML "document", but not the end of a YML "stream", which can contain multiple documents. It's the terminology that's causing confusion.
- ams6110 8y agoThat's interesting, I have always seen the three dots as the first line in a YAML file, my exposure to YAML being almost exclusively Ansible configurations.
- crdoconnor 8y agoHaving a strictly enforced schema is the ideal solution to this (and several other common problems with yaml). One really really nice aspect of YAML is how incredibly terse it is. That's a massive and very underrated boon for readability but the lack of syntactic cruft also means that it's much more susceptible to various type errors if it's parsed without a schema.