Hacker News new | ask | show | jobs
by guideamigo 1036 days ago
I wish it had comments. And for that reason, I prefer yaml.
3 comments

I prefer JSON's strictness. A Boolean cannot be confused for a string.

In yaml:

    country: no
Now your country is Boolean(false)

Now, I still prefer yaml overall.

Also, I hate that GitHub actions don't support anchors.

That's a false dichotomy. JSON could have comments and not be ambiguous like YAML.

In fact: there exists a specification called JSON5 which does include comments.

But I agree that it would've been nice if it had comments before it achieved a critical mass of adoption.

I've read the opinion that comments were omitted from JSON in order to forestall hacky round-trip conversions to/from other formats (like XML).

Can anyone confirm/deny ?

The primary reason why JSON does not support comments is that its creator, Douglas Crockford, deliberately removed them from the format to prevent misuse and keep it as a pure data-only format.

Crockford observed that some people were using comments to store parsing directives, which could break compatibility between different systems. Hence, the decision to remove comments to maintain the simplicity and consistency of the format across various programming languages and environments.

https://www.freecodecamp.org/news/comments-in-json/

I vote for the minimalist heretic.

https://www.infoq.com/presentations/Heretical-Open-Source/

I don't think they were saying that's an issue of comments, just an issue of yaml vs json.
In YAML 1.2 that gives the string "no".
Huh, that's a breaking change. yes/y/no/n/on/off are no longer boolean.

https://perlpunk.github.io/yaml-test-schema/schemas.html

Yes, it it. However, it's a breaking change that happened 14 years ago.
Except for many yaml implementations either not supporting 1.2 at all (pyyaml, ruby stdlib) or being a weird mix (goyaml) so as to keep working with older files.

So when you’re dealing with objective reality, this is still an issue today.

So that's been the spec since 2009???
This is the only example everyone points out against yaml.

For Json, there are several such syntactic problems. Unnecessary double quotes and only double quotes everywhere. No dangling comma.

These are different kinds of problems.

JSON is (arguably) too strict. YAML is (arguably) too loose. One is better for machines, the other is (usually) better for writing by humans by hand. There's no perfect compromise for every use case.

cries in TOML
There’s always JSON5
True, but the multi-line comments give me the ick, and there's still no standard for bigints.
YAML is a fine implementation of JSON with comments.