Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there a yaml without all the bells, whistles and magic?

Like the syntax (it doesn't turn non-techies off from changing some config values), but aren't a fan of all the magic whistles that can shoot you in the foot if you don't have near-encyclopedic knowledge of them.

The spec is too big for something that's supposed to just live in some of our configuration files.



YAML 1.2 removed some of the footguns like having five different ways of expressing `true`, but the main Python YAML package is permanently 1.1.

strictyaml is an attempt at tightening things further. But a lot of systems that use "yaml" don't implement any spec, because they write their own parser. For example IIRC gitlab ci doesn't support anchors but has their own code reuse construct.

And then there are all of the string templating extensions that projects like Ansible and Helm employ. These in my opinion are far worse than anchors and should be eschewed in favor of a non-static configuration like jsonnet.


I think JSON5 is fairly close to this: https://json5.org

I reckon the only thing it's missing to be truly accessible to non-techies is that string values still need to be quoted, i.e. you can't have:

key: this is my value

(I'm definitely not saying it would be a good idea to allow quotes to be dropped, just that that's the only potential stumbling block I see for non-techies.)

Edit to add: oh, hmm, I guess trailing commas are fiddly too. Possibly I want some even laxer variant of JSON that lets you use just newlines! :P


Hjson is very similar to JSON5 but allows quotes to be dropped and can use newlines instead of commas. There are implementations for a lot of different languages, I myself contributed the C++ implementation. I wanted something smaller than Yaml but more lax than JSON, found Hjson to suit my needs perfectly.

https://hjson.github.io/


This looks really nice, I like it!

JSON5 is elegant in that it's purely a subset of JavaScript (exactly as the original JSON is). But in practice that doesn't really gain you much besides a familiar syntax, and Hjson looks simple enough that the slight differences from JS shouldn't be a problem.

The real problem is how to persuade people to use something like this. For the few cases where JSON isn't already entrenched, YAML and TOML and the like have already salted the earth.


1 is a number, 01 is a string, 0.1 is a number, .01 is a string.

I prefer explicitly marking strings. If I try to write a number, I want confidence that I'll get either a number or a parse error. (Though that doesn't necessarily mean quoting the string, other methods could work.)


Non-techies can handle quotes fine.

Needing to deal with escaping can be a bit of an issue, though. The best option I've seen for that is [[the syntax for long quotes in lua]].


I'd suggest checking out TOML.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: