Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Skayo85686y<@filthyranter>
Depends on the parser you use doesn't it?
//edit
The specification doesn't mention anything about duplicate keys, so yes, it depends on the parser -
@Skayo Yep. Some parsers just overwrite the value, others panic because they already have the value.
-
(and some others even ignore the value, which is not that bad since it is supposed to be a comment anyway)
-
C0D4669026yIf you need comments, I’ve generally created a new key for comments which you can simply ignore and the parser won’t break.
{“_comment_for_key”: “something”, “key”: 123,”key2”:”something here”}
Sadly having actual comments in json would be so much nicer. -
(Many non-JS-parsers seem to use dictionaries. So they would just overwrite the value.)
-
C0D4669026y@gitreflog that looks like, let’s take something simple and make it work in any use case - and have standard parsers break like all hell. 😦
-
If you need comments, JSON is the wrong tool for the job. Can you use something like yaml instead?
-
@C0D4 watch, next feature request is if/else in JSON...
"If key X has value y I want to add key z"...
Why make JSON complex when it's only ment for simple data communication... -
C0D4669026y@incognito oh don’t give them ideas 😂
It’s bad enough I have to work with SOAP and JSON APis, I dont think I could handle conditional json too -
@incognito Because people are using it for something it wasn't meant for. On the bright side, JSON feature requests aren't a thing. The standard is fixed.
I wish a better standard for config files would take off. I'm not really a fan of yaml and ini files look ugly. Json is almost there, it just needs to be a little less strict and allow comments. People try to make a nice standard all the time but it never takes off -
inaba45896y@filthyranter fixed it no problem
{
"1": {"//": "This is not a comment"},
"2": {"hello": "bar"},
"3": {"//": "world"}
} -
@inaba LOL this is either the best meta joke of all time or you’re actually being serious. I will go with the former since it’s really more funnier that way
-
git-gud14066yno offense, but...
don't use json? my personal favourite replacement is yaml, which is reasonably well supported (save for web apis where you don't have comments anyways), but there have to be alternatives.
except xml, that's even worse -
Skayo85686y<@git-gud>
Yeah but YAML always needs to be properly formatted. JSON can be in a single line. -
git-gud14066y@Skayo when is that a criterium, do you want to minimize it by removing whitespaces?
-
Skayo85686y<@git-gud>
No but I hate languages like python and yaml where the correct indentation is important -
git-gud14066y@Skayo well, i love them, because that removes the need for brackets, but whatever floats your boat i guess
-
@M3m35terJ05h you might wanna take a look at TOML then https://github.com/toml-lang/toml
Related Rants
I always wanted to have comments in JSON files, but I just discovered a really good alternative:
{
"//": "This is a comment",
"somekey": "somevalue"
}
Looks kinda ugly but it works! No need for special unconventional parsers and shit.
random
json