A 10 minute read covering some YAML edge-cases that you should have in mind when writing complex YAML files

  • The problem is there aren’t really any good alternatives that have as widespread support. I’ve looked at lots and always found some annoying flaw that JSON or YAML don’t have. I mainly want good support in Python, Rust and VSCode.

    • JSON5: This is my ideal alternative but it has surprisingly poor support. No good VSCode extension. There’s a Serde crate but it’s not very popular.
    • Jsonnet: This has great VSCode support and support for lots of languages including Rust, but for some inexplicable reason they won’t let you use it with Serde just to load documents.
    • TOML: This is just not a good format. It’s ok for very basic things but any level of nesting and it becomes even worse than YAML.
    • Cue: Only supported language is Go.

    There isn’t really a perfect option at the moment IMO.

    If I’m using Rust I tend to go with RON at the moment. Sometimes I do use YAML but I write it as JSON (since YAML is a superset of JSON) with # comments.

    Also never output YAML from your programs. You can always output JSON instead which is better.

    • @umbraroze@lemmy.world
      link
      fedilink
      3
      edit-2
      4 days ago

      My hierarchy goes something like this:

      • A relatively trivial configuration file? TOML
      • A configuration file that needs a bit of complexity and nesting? YAML
      • Is it getting so complicated and longwinded that you’re actually unlikely to touch it by hand anyway? JSON
      • Have we become downright enterprisey? XML