json was intended as a messaging format rather than a storage format; the fact that it doesn't support comments out of the box is because it wouldn't make as much sense for a message to have comments attached.
It wasn't intended as a format for configurations, no. That it *can be used* as a configuration file format is one part overlap between the requirements of a configuration file and of a messaging format, and two parts willingness to ignore the places where json just doesn't have all the things a configuration format needs (such as comments.)
I guess it's a bit like using a wrench to hammer in a nail. The nail will end up in place, but it takes a bunch more work and won't ever be as nice as using a proper hammer.
I fucking hate yaml and I’ll fight people about it. It is so obnoxious to use for anything larger than thirty lines. I need brackets to see where things go once we get to the point that the whole thing doesn’t fit on a monitor.
people don't use it because it's designed for configuration (which it isn't), people use it because of how easily it translates into an object, which is somewhat good for configuration.
Not sure with whom you are forced to work with but in all companies I worked so gar, not reinventing the wheel was the norm (ok some npm packages that only house one or two very simple finctions are busted but other than that...).
I wish it was just about reinventing the wheel. Our tiny web app project we made for uni ended up having like 5 different packages for password encryption and our final version used 0 of them
We're talking about web apps here. "real world" is more likely to mean a random inexperienced person or a low-budget team, and people like that will make even more mistakes than out team of undergraduates did at something as high-level as dependency management.
With that in mind, it's best not to have commonly desired features such as comments in JSON locked behind an extra dependency.
all of them are just text files. It's not .json that don't support it, it's your json parser. For example in C# I can easily ignore comments when parsing json.
The json standard explicitly does not allow for comments iirc.
Also you probably should respect conventions when it comes to file types. All file formats are just strings of bytes, but nobody is arguing that .png files should be able to include json and comments, even though you technically could make a fork of libpng that supports those things.
If you get a .png file, you expect it to conform to the png standards so you can open it with any image viewer.
The same should be true with other formats. You should be able to reliably open any .json file with a parser that conforms to the json standard.
Keep in mind docs are not for you they're for others. I wish I could say these commands are self descriptive but I literally had a jr ask me what those two npm commands do.
Honestly I've seen this quite a lot or things like _comment as the key. I don't like it that much but it's not terrible if you absolutely 100% need to include a comment in your config.
It doesn’t look great and doesn’t make sense for normal easily to understand scripts. However the guy writes a lot of code for introductory courses so it may help someone new to node figure out what’s going on when they go back to look at the code a couple a few weeks or months after taking the course. When you are new it may not be appearing that this would be in the readme file and I have had to point it out to some JRs. Also I have seen some long drawn out scripts that may have been self documenting to the creator but make no sense to someone without digging through layers of scripts. So i don’t care if they are in the Readme or ugly like here in the package.json just put some documentation somewhere.
I'm not contacting reactjsconsulting.com for anything.. What other basic things don't they know about js and json? I mean its even highlighted that it will interpreted as key-values
This is why you certifications for your employees and code reviews for your code.
13
u/eerklogge Mar 20 '22
Everyone who will read this file will know what the start and test scripts do, it’s self explanatory, why the hell would you need to comment that?
203
u/[deleted] Mar 20 '22
.jsonc or .json5 files both support comments, but .json doesn’t let us have these nice things
256
u/blehmann1 depraved Mar 20 '22
Ah shit bro, I thought the script that says start was the one that stops the app. Good thing you had those comments.
47
u/Southern_paw Mar 20 '22
Wow, if only there was like ... some sort of README file these could be documented in
38
u/everdreamz Mar 20 '22
“Reactjsconsulting”
71
u/[deleted] Mar 19 '22
Makes no sense…Lol, why not just descriptively name the command in the first place.
4
u/nolawnchairs Mar 20 '22
If you have to describe what it does, you've named it wrong.
7
u/[deleted] Mar 20 '22
I've had people tell me this guy is a react js god and then I see shit like this....
12
u/djlowbal Mar 20 '22
“//The below is a comment”: “”, “//Commenting the obvious”: “”
18
u/[deleted] Mar 20 '22
I think you don't know what README.md file is for
4
u/WK02 Mar 20 '22
npm run //start6
u/TheHaitianPopulation Mar 20 '22
Heh, at my job we add properties like
"_supplemental": "some comment"
3
u/GustavoCinque Mar 20 '22
"DoCuMeNtAtIoN"
2
u/[deleted] Mar 20 '22
My team uses these but more for labeling sections of the scripts, not documenting each individual one.
2
u/626f776572 Mar 20 '22
Honestly I've seen this quite a lot or things like
_commentas the key. I don't like it that much but it's not terrible if you absolutely 100% need to include a comment in your config.2
u/obiwac Mar 20 '22
To be perfectly honest, I'd have done the same thing out of protest. I find it dumb beyond comprehension that vanilla JSON doesn't have comments.
3
u/[deleted] Mar 20 '22
Why not make each script its own object with a command and comment property? E.g. "start":{"cmd":"react-scripts start","comment":"Yada Yada"}
1
u/carcigenicate Mar 20 '22
Lmao, I'm curre tly taking a course of his on PluralSight.
I'll just... ignore the best practice recommendations.
1
u/iMakeLoveToTerminal Mar 20 '22
Wut? I can comment shit in my Vscode config. Vscode uses a different parser for config files ?
1
u/SwarmsOfReddit Mar 20 '22
Vomit inducing.
1
u/[deleted] Mar 20 '22
wtf would even be the point of this
1
u/xzorandar Mar 20 '22
It doesn’t look great and doesn’t make sense for normal easily to understand scripts. However the guy writes a lot of code for introductory courses so it may help someone new to node figure out what’s going on when they go back to look at the code a couple a few weeks or months after taking the course. When you are new it may not be appearing that this would be in the readme file and I have had to point it out to some JRs. Also I have seen some long drawn out scripts that may have been self documenting to the creator but make no sense to someone without digging through layers of scripts. So i don’t care if they are in the Readme or ugly like here in the package.json just put some documentation somewhere.
1
u/[deleted] May 10 '22
Just fucking delete them
1
u/AlternativeBorger Aug 24 '22
Thats why i prefer YAML
1
u/fletku_mato Mar 20 '22
Imagine needing a comment to tell you what "start" does.
-7
u/fredrik_skne_se Mar 20 '22
I'm not contacting reactjsconsulting.com for anything.. What other basic things don't they know about js and json? I mean its even highlighted that it will interpreted as key-values
This is why you certifications for your employees and code reviews for your code.