40

No comments allowed in JSON pisses me off so much.

Sure, I get all the arguments of "it's supposed to be a data-only format for machines", "there are alternatives which support comments", and "you can add comments and then minify the file before parsing"

But right now, when I just need to put a quick note inside a super confusing legacy package manager config about why certain dependencies to be frozen at a specific version, IT FUCKING PISSES ME OFF THAT I CAN'T JUST ADD A FUCKING COMMENT.

Comments
  • 28
    {"_note": "this node eats pie"}

    About as good as I've gotten to a comment in json
  • 1
  • 4
    It's a data transfer format. Using it for config is already a bad idea, precisely because config files need some things JSON never needed.
  • 6
    @Lor-inc I agree that there's nicer options for configuration files — the problem is that the developer isn't the one who chooses JSON, it's the framework or package manager maintainer.

    I would rather use TOML or YAML, or even just set up the config as a module/script source file in the same language as the rest of the project... But it's not like I'm going to fork Composer or Yarn just to make it TOML-compatible.
  • 0
    @C0D4 I've seen that done. I don't 'like it' it seems 'wrong' ... but it's also something I wouldn't argue against.
  • 0
    Write a test that breaks on a version upgrade?
  • 1
    @C0D4 It can break systems though.

    I mean, add it to package.json, and npm will probably complain that it can't find a package called "__note"
  • 6
    @json wanna comment?
  • 3
    No its completely valid, when I found out you cant comment in it I was pissed
  • 1
    used to have the same thought. I moved on.
  • 1
    @C0D4 How's the pie?
  • 0
    @bittersweet use cases will vary sure,
    For npm this is probably the cleanest and safest way to achieve that.

    https://www.npmjs.com/package/nps
  • 0
    @kamen sweat Apple Pie 🤤
  • 2
    @C0D4 sweat pie 🤮
  • 1
    @C0D4 Haha yes the solution in the JavaScript ecosystem is always "I think we need a bigger toolchain" 😆
  • 1
  • 0
    Have you tried JSON5?
  • 0
    @pxeger @Berkmann18 Call me when JSON5 is not just used by devs, but also by package managers and as framework configs.

    It's not so much "there are no solutions", it's "adoption rate of possible solutions is low"
Add Comment