this post was submitted on 13 Nov 2023
107 points (82.4% liked)

Programmer Humor

19821 readers
56 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 2 years ago
MODERATORS
 

And I'll show you YAML

(a continuation of this post)

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 20 points 1 year ago (3 children)

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)

[–] [email protected] 25 points 1 year ago (1 children)

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

[–] [email protected] 4 points 1 year ago (1 children)

And also a standard date time type!

[–] [email protected] 6 points 1 year ago (1 children)

What is wrong with ISO 6801 strings?

[–] [email protected] 6 points 1 year ago (1 children)

11-2023-14

I dunno it just kinda looks weird to me

[–] [email protected] 2 points 1 year ago (1 children)

Dunno what format you've got there, but ISO 6801 looks like 2023-11-15T18:28:31Z

[–] [email protected] 3 points 1 year ago (1 children)

It's a joke, because the standard is 8601, not 6801.

[–] [email protected] 3 points 1 year ago

Oh. Egg on my face then lmao I didn't even notice

[–] [email protected] 4 points 1 year ago* (last edited 1 year ago)

JSON5 has comments, among fixing a few other shortsighted limitations of the original.

[–] [email protected] 1 points 1 year ago (1 children)

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 //.

[–] [email protected] 2 points 1 year ago (1 children)

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.

[–] [email protected] 1 points 1 year ago

I've disagreed with JavaScript before, what makes you think I won't do it again?

Anyway, anything using JSON as a config language will also certainly use a JSON interpreter that can ignore comments. Sure that's "implementation specific," but so is a config file. You wouldn't use "MyApplication.config.json" outside the context of MyApplication loading its own configuration, so there's no need for it to be strictly compliant JSON as long as it plays nicely with most text editors.