And I’ll show you YAML

(a continuation of this post)

  • DrM@feddit.de
    link
    fedilink
    arrow-up
    17
    ·
    1 year ago

    JSON would be perfect if it allowed for comments. But it doesn’t and that alone is enough for me to prefer YAML over JSON. Yes, JSON is understandable without any learning curve, but having a learning curve is not always bad. YAML provides a major benefit that is worth the learning curve and doesn’t have the issues that XML has (which is that there is no way to understand an XML without also having the XSD for it)

    • Michal@programming.dev
      link
      fedilink
      arrow-up
      21
      ·
      1 year ago

      Json should also allow for trailing commas. There’s no reason for it not too. It’s annoying having to maintain commas.

    • Kogasa@programming.dev
      link
      fedilink
      arrow-up
      4
      arrow-down
      2
      ·
      1 year ago

      If a comment isn’t part of the semantic content of a JSON object it has no business being there. JSON models data, it’s not markup language for writing config files.

      You can use comments in JSON schema (in a standardized way) when they are semantically relevant: https://json-schema.org/understanding-json-schema/reference/comments

      For the data interchange format, comments aren’t part of the JSON grammar but the option to parse non-JSON values is left open to the implementation. Many implementations do detect (and ignore) comments indicated by e.g. # or //.

      • frezik@midwest.social
        link
        fedilink
        arrow-up
        1
        ·
        1 year ago

        JSON models data, it’s not markup language for writing config files.

        JavaScript package management promptly said otherwise. JSON is a config format no matter if you like it or not.