.yaml, .toml, etc?

  • @[email protected]
    link
    fedilink
    English
    152 years ago

    A lot of good answers but I would add one note:

    • use a format that supports comments, and JSON is not one of those…
    • @[email protected]
      link
      fedilink
      English
      152 years ago

      Of course it does!

      {
        comment: "This data is super important and it runs the system or something",
        data: ["Some", "stuff", "here"]
      }
      
        • @[email protected]
          link
          fedilink
          English
          12 years ago

          It’s so easy to use, and you can read the comments from in your program too!

          ^(in case you weren’t just playing along, please never do comments this way)

          • @[email protected]
            link
            fedilink
            English
            12 years ago

            I liked the idea to be honest. I can just call the entry “description” instead and all is good ^^

            • @[email protected]
              link
              fedilink
              English
              22 years ago

              Ideally, you would use TOML for human-readable configuration and document your JSON API with external documentation instead of sending comments around a bunch. If you need to display the description to the end user though, that would be a valid use case.

        • @[email protected]
          link
          fedilink
          English
          12 years ago

          Please don’t actually do this. Comment stuff in the code and documentation, not the JSON.

          • @[email protected]
            link
            fedilink
            12 years ago

            Don’t worry, I wouldn’t do things like this in JSON. Nevertheless, it can be very useful to have comments along with configuration values, for example to explain the actual values (not their purpose) and why they were chosen. That’s information you can’t add to the code which processes the values.

    • @[email protected]
      link
      fedilink
      22 years ago

      json with comments can be parsed by a yaml parser. It’s how I write yaml, in fact (yaml is a superset of json. any valid json is valid yaml, but it also supports comments)