3 ms·
> The rest of the problems can be solved by quoting your strings. How do I get all of YAML's millions of other users to quote all of their strings? What about
by smt88 5y ago
> The rest of the problems can be solved by quoting your strings.
How do I get all of YAML's millions of other users to quote all of their strings?
What about programmatically generated YAML?
Also, you're entirely ignoring two other major issues: meaningful whitespace (making YAML hard to read and write) and multiple ways of doing the same thing (making it confusing).
- Spivak 5y agoThe best practical advice I can offer: - For your own projects use yamllint, put it in your CI pipeline, and your pre-commit hooks. You can forbid the use of flow sequences like [ and {, require quotes, and forbid truthy values for bools. - USE JSON-SCHEMA. It works on YAML. - For programmatically generated YAML just generate JSON and call it day. - If you have a tool that for some reason requires YAML but not JSON then don't write YAML. Write your config in $programming_language and only dump the YAML at the end. Troposphere is a Python library for CloudFormation JSON that embraces this idea. - Don't template YAML files (or JSON for that matter). Again just use variables in your programming language of choice and then dump. Helm is an abomination and the authors should be ashamed of themselves. Ansible had the common sense to only allow templates in the values instead of at the file level.
- smt88 5y agoWe pretty much just use JSON exclusively, since JSON is also valid YAML (another bizarre design decision in YAML, but a blessed escape hatch for me). That is, I suppose, a strike against YAML: we just "downgrade" to JSON and never have any issues.
- bmn__ 5y ago> JSON is also valid YAML That's false. http://p3rl.org/JSON::XS#JSON-and-YAML http://p3rl.org/JSON::XS#JSON-and-YAML
- GoblinSlayer 5y agoOuch, I routinely see \/ in json in the wild. What happens outside of BMP? JSON escapes surrogate pair as two UTF-16 code units separately.
- smt88 5y agoThat link is from more than 10 years ago and is no longer accurate as of YAML 1.2[1]. Perfect JSON compatibility has always been a stated goal of YAML and is something they consider to be a bug when it's found to be broken at the spec level. 1. https://yaml.org/spec/1.2.2/ https://yaml.org/spec/1.2.2/
- bmn__ 5y agoIf you read the linked document carefully, then you will notice that YAML 1.2 existed twelve years ago, the incompatibility has not been addressed as suggested and remains still a problem for the end users.
- diob 5y agoWait really? I never knew that. I absolutely fail at whitespace delimited things like YAML and Python, I just can't handle it mentally.
- smt88 5y agoIt's true. YAML is a superset of JSON[1]. I agree that it is surprising (in a bad way) and makes no sense. 1. https://octopus.com/blog/state-of-config-file-formats#:~:text=Although%20YAML%20looks%20different%20to,JSON%20in%20its%20configuration%20files https://octopus.com/blog/state-of-config-file-formats#:~:tex....