r/ProgrammerHumor • • 11d ago • Bravo 1

Meme commentsInJson

Post image
6.0k Upvotes

202 comments sorted by

598

u/captain_crocubot 11d ago

I present to you the humble: jsonc

224

u/Positive_Mud952 11d ago

That’s the great thing about standards…

19

u/lraviel381 11d ago

Just make a new one as you go

60

u/IC3P3 11d ago

json5, json6, hujson and hjson as well

25

u/MrHyperion_ 10d ago

jsonl

No comments but it is another extension

7

u/benargee 10d ago

that's just a file that contains many lines of single line json.

8

u/MrHyperion_ 10d ago

But not valid json so it is separate extension ¯\(ツ)/¯

0

u/benargee 10d ago

I don't think I disagreed with that. its basically lines of json objects. each line is valid json. you don't interpret the whole file as valid json. It's basically a very simple intermediate filetype.

6

u/Turbulent_Stick1445 10d ago

I feel like JSON5 or JSON6 are our best hopes, because they sound purely like the latest version of JSON and not independent forks, so you have at least a small chance of being able to yell at a vendor "Why doesn't this support JSON6 yet? You're way behind the curve! Next you'll be telling me you don't support Python 4!"

6

u/benargee 10d ago

Yes it exists but adoption is poor. You basically have to convert it into json before or during runtime.

967

u/nameless_pattern 11d ago • Bravo

You can add anything you want to Json. just make a property called comments

268

u/tokalper 11d ago

I Just create some fields names "__"

150

u/metaglot 11d ago

Tell me you only work on your own, without telling me you only work on your own.

92

u/tokalper 11d ago

No, precisely because i work with a large team. We work eith large json files for configurations and they need commenting, we all do this.

65

u/the-liquidian 11d ago

JSONC was created for this.

86

u/AnotherPillow 11d ago

More annoying to load. Most languages have builtin json parsing, but rarely jsonc and similar support

9

u/Devatator_ 10d ago

C#'s System.Text.Json will reject comments by default but you can configure it to accept and even parse them if you want to read their content

19

u/Slight-Violinist-575 10d ago

Comments are for humans lmao

9

u/Devatator_ 10d ago

I mean someone could make some fucked up preprocessor using comments

8

u/Slight-Violinist-575 10d ago

I am sure someone could, and I am sure someone eventually will, and we will pay for it

→ More replies

5

u/Turbulent_Stick1445 10d ago

There is a use case for reading comments (though it really needs to be optional) which is if your code is editing the JSON rather than just getting information for it.

eg:

configObject = loadJSON(".config/myapp/settings.json");
configObject.enableCrashes = true;
configObject.write(".config/myapp/settings.json");

But that means a fairly ugly JSON parser that would have to store a lot of positional information. I mean, it can be done, but...

1

u/TerminalVector 10d ago edited 10d ago

Man, what was it? Backspace? Backslash? Some kind of html templating language I had the displeasure to work with in one of my first jobs that used magic comments. I remember my onboarding buddy telling me they didn't do anything, and then discovering that no, they in fact drove the layout of the entire page. He'd been with the company over a year, and wasn't an idiot. It just doesn't make any sense and he hadn't really checked.

1

u/Slight-Violinist-575 10d ago

Jade/Pug? I once was a padawan and thought that was hella cool when I first learned about it.

Then life thought me to appreciate explicit boundaries, in every sense.

→ More replies

1

u/YeOldeMemeShoppe 10d ago
// #[agreed]

3

u/Scolmann 11d ago

It's not too hard to strip out comments with a regex, but yeah generally you wouldn't bother with stuff like that

2

u/the-liquidian 10d ago

Or use an existing tool to transpile it.

0

u/[deleted] 10d ago

[deleted] — view deleted comment

15

u/Jonathan_the_Nerd 10d ago

3

u/korneev123123 10d ago

Thanks for the link. 22:22 and "Norway problem" are hilarious. I guess I have an excuse now for aggressively quoting everything. Also jsonc looks like much, much better alternative for future projects.

5

u/tokalper 10d ago

You gotta work with what you've got

58

u/DiamondDramatic9551 11d ago

I also always declare comments as unused variables in my code.

20

u/nameless_pattern 11d ago edited 11d ago

Heresy. I love it, I'm going to start making unused functions as comments, no I'm going to start embedding AIS you have to chat with to get the comments and they will only tell you the comments if you solve a riddle

7

u/YoghurtFlan 10d ago

i prefer to keep them on the stack just in case the CPU gets confused

5

u/rinsa 10d ago

Even though the compiler would basically ignore it, the linter/analyzer wouldn't like it :(

11

u/innociv 10d ago

Am I out of touch? No. It's the linter who is wrong.

1

u/innociv 10d ago

Like?:

{
        "key": "value",
        "comment about key or this block"
}

9

u/spicybright 10d ago

well that wouldn't work, you'd need it like

"comment": "comment about key or this block"

10

u/Ahchuu 10d ago

I do this, I have a field called "//". Easy

19

u/HipstCapitalist 11d ago
{"__comment__": "A comment"}

14

u/meifray 10d ago
{
    "key":"value",
    "key_comment":"le comment"
}

2

u/Cisco-NintendoSwitch 10d ago

Shitpost aside do people actually do this? I’m a Platform Engineer so YAML all day (Terraform / Ansible)

7

u/stipo42 10d ago

Then your marshalling library throws "unexpected key"

3

u/TerryHarris408 10d ago

they do that? I need to get my nlohmann up to that point. would help me a lot with schema migration tests

2

u/TerminalVector 10d ago

It's usually a config option to either error or silently discard an unexpected key

2

u/Meltz014 10d ago

"additionalProperties": false

1

u/stipo42 10d ago

Some do, some don't, some can. Just read the docs

13

u/john_the_fetch 10d ago

But they want it in line.

Like :

i added the prod key here until staging is fixed

{key:"omgIsThisYourProdKey?fs*dsjs"}

3

u/nameless_pattern 10d ago

All text comes in lines

1

u/techek 10d ago

They obviously don't know anything about what you really do, but they still have an idea about how you should do it.

I'm sure they press <Enter> at the end of each line in Word, to get a new line - and then curse when everything look like shit after adding/removing one single word.

1

u/Vesuvius079 9d ago

Which is worse, seeing this comment in json or the act it describes?

6

u/mothzilla 10d ago

Oh no, you see boss says it shouldn't be in the JSON. It should be a comment. We don't want people to be able to read our comments.

3

u/nameless_pattern 10d ago

I never read comments. It's the best way to enjoy Reddit

16

u/Turbulent_Stick1445 10d ago

This is what I do, but there are two problems with it:

  1. A parser will end up storing the comments, wasting memory.
  2. You run into JSON's problems with multiline string constants if your comment is anything but trivial.

It gets ugly fast.

4

u/Sockoflegend 10d ago

We use node where I work so it just happened to be easier to have config type json files just be a JS import 

3

u/zoinkability 10d ago

Plus: maybe you don’t want the client to read your internal comments like “todo: close this security issue” or “added because the client is an idiot”

2

u/nameless_pattern 10d ago

You could keep them just in Dev deployments?  lot of messy trade-off choices

4

u/Turbulent_Stick1445 10d ago

The #1 place I've seen comments in JSON are where someone makes the mistake of using JSON for a configuration file format. The lack of support for comments is ironically why even XML is a better choice for that. Regardless, you can understand why people would want comments there outside of just dev environments.

(I just learned as of two hours ago that YAML can be used with JSON syntax so I guess it's academic, just use YAML...)

1

u/AnnoyedVelociraptor 10d ago

In Rust if you map a JSON object to a struct, and you don't have a field mapped for comments it gets dropped.

1

u/them0use 10d ago

No problem, just make `comments` an array! I am dead inside.

1

u/Turbulent_Stick1445 9d ago

I have done exactly that :( Now I know YAML can be written like JSON though I'm probably going to just switch to that in future as YAML has almost as much support as JSON. I'd only been avoiding it because I thought the indenting-is-meaningful syntax was mandatory.

1

u/d_maes 10d ago

3. Only works if you control the schema, or the target does not enforce a strict schema.

5

u/Successful-Active-21 11d ago

but it will collide with someone's field comments

24

u/einzweidreihorn 11d ago
{ "__COMMENT_DO_NOT_USE_OR_YOU_WILL_BE_FIRED": "Hello world!" }

3

u/BigNaturalTilts 10d ago

It collides with my “comment I used because yolo”

2

u/another_random_bit 11d ago

elegance ✨✨

2

u/destroyerOfTards 10d ago

Watch me speedrun my way into getting fired from the shitty company

1

u/No-Finance7526 10d ago
{
  "comment_eifjefjefje": "This is a comment.",
  "comment_wodkwowowow": "This comment avoids collisions."
}

4

u/YesterdayDreamer 10d ago

Schema validation is a thing

5

u/nameless_pattern 10d ago

I support all schemas

4

u/thecrius 10d ago

That's the way.

7

u/protestor 10d ago

This doesn't work for tools that actually validate the schema of the json they receive

4

u/nameless_pattern 10d ago

You can add comments to the schema. Hold on my boss said they needs to talk to me privately 

3

u/hrvbrs 10d ago

Not if you’re adhering to a schema

1

u/nameless_pattern 10d ago edited 10d ago

With the power of AI, I can add things to the schema long before it becomes noticed that that's a terrible idea

5

u/JollyRancherReminder 11d ago

This works if you're only using it internally. Don't try this with your API's output.

174

u/pregister 11d ago

66

u/Chasar1 11d ago

This solves every gripe I have with json

28

u/foxsimile 10d ago

Yes. I’m struggling to think of an unaddressed complaint, which is rare for me.

13

u/EuenovAyabayya 10d ago

Supported on all your platforms?

5

u/foxsimile 10d ago

I just kind of took the lack of universal support one as a given ¯_(ツ)_/¯

4

u/MaximRq 10d ago

Unfortunately my train platform doesn't support it

7

u/Librarian-Rare 10d ago

Fr, why isn't this the whole world now??

5

u/YeOldeMemeShoppe 10d ago

It also actually solves edge cases where the JSON spec cannot read valid JSON.

2

u/innociv 10d ago

... I just don't even think about putting \\n at the end of a line and stuff. I never really had a gripe. I guess I've just been someone who is good at following instructions and I don't question this stuff.

9

u/mrheosuper 10d ago

Wait there are json1, json2, json3 and json4 ?

11

u/lachlanhunt 10d ago

No, it was named JSON5 as a subtle nod to HTML5, because it fixed a lot of stuff with the original format when using it for use cases like config files.

1

u/mrheosuper 10d ago

Wait you mean there are html1, html2, html3 and html4, jesus what else does the world hide from me ?

5

u/Alone_Term5356 10d ago

HTML 5 came out in 2008, anything older than it is basically not on the internet anymore, and sucks. About the only holdovers from old html stuff (by that I mean stuff that isn't valid anymore but still occasionally happens by beginners ) is <i> for italics and <b> for bold.

1

u/Western-Anteater-492 10d ago

That's the great thing bout json5! It's so great it completely jumps 1 to 4.

22

u/audigex 10d ago

Or YAML

… because JSON is valid YAML syntax, for some reason

18

u/AlwaysHopelesslyLost 10d ago

Because yaml is just a bolt on extension of JSON. It is json but it lets people omit most of the critical control structures in favor of inferring from whitespace characters.

13

u/Habba 10d ago

I really hate yaml so much. It's both terrible to write as a human, super easy to get wrong indentation on stuff and it's famously horrible to parse.

4

u/gogliker 10d ago

No getting parsed as Norway was my all time favorite with YAML parsers. I think TOML is better though

1

u/Habba 10d ago

TOML is indeed better for a lot of things, especially config. Not sure about other places yaml gets used, like in defining CI pipelines. I hate yaml there too however, it always takes me 3 times to get the right incantation for a variable interpolation.

I think something like Jenkins is better there, since its actual code, but Groovy also sucks.

1

u/caboosetp 10d ago

 omit most of the critical control structures in favor of inferring from whitespace characters

So what you're saying is that yaml is python for json.

9

u/voyagerfan5761 10d ago

I did not need to know that.

Someone fetch me a time machine…

1

u/Turbulent_Stick1445 10d ago

WHY AM I NOW ONLY HEARING ABOUT THIS?

(From what I'm reading it's MOST JSON is valid YAML, but there are differences: JSON allows tabs for indenting, and has some slight differences with escaping - like "\/" is valid JSON but invalid YAML. Surrogate pairs in JSON written like "\uD83D\uDE00" need to be written as "\U0001F600". Bottom line, be aware there are differences, but the main feature of YAML's JSON compatibility is that if the YAML indenting thing isn't very readable to you, you can just write stuff in a more JSON-like way, which, after decades of C and Java and Javascript programming, most of us are used to.)

1

u/Hax0r778 10d ago

JSON doesn't have indenting?

I mean, it fully ignores white-space outside of strings so you could add whatever random tabs you want in your JSON file. But I wouldn't call it indenting if it has no meaning and is ignored by all valid JSON parsers...

1

u/Turbulent_Stick1445 9d ago

JSON has optional indenting where the tab is just generic white space you can use without it impacting anything. You do not need to indent something in JSON, and it's only meaningful to human readers if you do.

However, tabs ARE meaningful in YAML, under certain circumstances they affect how the file is parsed.

1

u/FerusGrim 9d ago

What the person was saying is that JSON doesn’t “have” optional indentation. It’s just meaningless, and ignored.

1

u/Turbulent_Stick1445 9d ago

OK, I'm still unsure what was read in my original comment that the GGP was generating a warning message.

Point was simply if you indent lines of JSON with tabs, you're going to run into trouble if parsing it with a YAML parser. Whether JSON considers indenting to be significant is really irrelevant to that point, people indent JSON just as they indent Java, C, etc. I never wrote anything that I feel can be remotely interpreted as "If you indent JSON, JSON will consider the indenting to be significant and interpret it differently" but maybe you're seeing something there?

1

u/FerusGrim 9d ago

I don't think you're being misunderstood. I, and I'm pretty sure everyone else, already knows what you mean. It may be a bit pedantic, but the point being made is just that the way you were referring to using indentation was as if it was some property that JSON had, or was capable of. That's why I used "have" in quotes. But JSON doesn't really "have" the "feature" of indentation, it's just... uncaring of it.

1

u/thecrius 10d ago

A configuration language in which spaces are determining it's meaning

Fuck. That.

1

u/audigex 10d ago

To be fair I’ve always figured YAML is more aimed at “very easy to read by humans, but should be primarily read and written by the computer”

It feels more like a computer-focused config language that happens to be convenient to read

2

u/enigma_0Z 10d ago

Idk this looks like yaml with extra steps for the most part. You can write bastardized json with bare identifiers etc in yaml and it parses fine. Including iirc curries and squares to replace the white space and “-“ indentation notation if you want.

Edit: Then again if you are writing a config file for humans (ie why you want comments in it), JSON (with or without comments) maybe is not the right choice to start with /IMO

-1

u/Engine_Light_On 10d ago

in python you need to install a new dependency, not worth it in every script.

81

u/buckinin 11d ago

Comments do exist: { "$comment": "Hello World" }

56

u/proverbialbunny 11d ago

{ "$developers_note": "I was drunk when I wrote this. Good luck!" }

8

u/buckinin 11d ago

Pull Request denied.

11

u/LatvianCake 11d ago

git checkout master

git merge mybranch

git push -f

9

u/LuisBoyokan 11d ago

LGTM, approved

14

u/metaglot 11d ago

Hello, validation hell.

3

u/Striky_ 11d ago

If you want to validate your data, don't transmit it as a string in the first place.

10

u/metaglot 11d ago

Nothing wrong with strings. Data is data. Strings can be validated jus as everything else.

2

u/necrophcodr 11d ago

Plenty wrong with having to decode a full JSON object just to fail validation after.

2

u/RevoOps 11d ago

You can technically build a dwelling out of blocks of ice. Doesn't mean you should do it if you are building a house in Florida 

5

u/another_random_bit 11d ago

Ok but that's irrelevant? Strings CAN be validated, and sometimes the data is in string format.

What does houses in Florida have anything to do with it?

1

u/buckinin 11d ago

Oh, just because they exist doesn't mean people should use them.

0

u/metaglot 11d ago

Schemas can go fuck themselves?

3

u/MrHyperion_ 10d ago

You can attach comments only to blocks then, not simple variables unless you do something really perverted like

 "variable": "value";
 "variable__comment": "the comment";

65

u/mortalitylost 11d ago

I used to like comments in yaml

Then I kept running into situations where automation that parsed those comments would've been helpful... It made me hate the fact they exist in the first place.

Either that description or metadata should be serialized into the same object it describes or it shouldn't exist in the same document IMO

80

u/herrkatze12 11d ago

Comments are specifically useful for config data, and should just be human readable descriptions of what the field does.

35

u/noaSakurajin 11d ago

Also they allow you to test changes to the config by simply commenting out that line. When editing Configs over ssh this is significantly faster that removing the line and is easier to revert.

7

u/Ixaire 11d ago

Yes but parsing comments to render them in documentation is definitely relevant.

That's why Knuth invented literate programming: https://en.wikipedia.org/wiki/Literate_programming

And that's also why XSD has specific documentation fields in addition to the standard XML comments.

1

u/herrkatze12 11d ago

That's actually one case where it might be useful

2

u/daveswe 11d ago

Weeeellll ix you have to make yaml files which are parsed by someone else according to a very strict model with shit names comments are a lifesaver :p

7

u/notexecutive 11d ago

you can't just add comments in the JDSL alright? They ruin everything and will get you fired! Tom is a genius!

6

u/weirdbackpackguy 10d ago

Comments in Jason? I think that's called a tattoo

11

u/Random_-account 10d ago

Who is JSON?

7

u/takahashi01 10d ago

json programming, the inventor of rudely telling computers what to do. He has refused to comment on a current political issue and is now getting canceled over this

6

u/Bata600 10d ago

Json Momoa

2

u/Turbulent_Ebb_9741 10d ago

You mean Jason my buddy

1

u/newontheblock99 10d ago

Former CEO of Nvidia

10

u/Waltekin 10d ago

Yeah, please not. The greatest thing about JSON is its simplicity. The entire spec is only 16 pages long. Don't mess it up.

9

u/da_Aresinger 10d ago

Adding comments to the spec would add 2 sentences.

Comments are initiated by ___ and can appear at any point, in any line.

___ can be escaped using ___, to prevent creation of comments.

Smarter people than me would express themselves better. Maybe add one or two sentences.

But comments are not complicated.

I have implemented comment parsing in Bash. If I can do that, anyone can.

3

u/Fluffy_Dragonfly6454 10d ago

It is not that simple.

What about backwards compatibility? When you add a comment, your old parser will fail.

What about a string? Should you also allow a comment there? That will make parsing more difficult. What with multi line JSON?

Also a lot of JSON simplifications is put everything on one line. Hence, you should have a comment that can stop and continue on the same line...

4

u/aa-b 10d ago

Behold, the entire JSONC spec: https://jsonc.org. Compatibility problems? Solved.

2

u/Cafuzzler 10d ago

Both are wrong, and we should add another comoeting standard. I propose # comment!

2

u/da_Aresinger 10d ago

That's not really an argument against comments, but against changing established standards.

And I agree, you shouldn't start sending commented JSON to systems that don't support it.

But if you're building something new, there is no harm in it. Just make sure to strip all comments before communicating with external systems.

My point only adresses the argument that comments would be too complex for JSON, when they clearly don't add much complexity at all.

1

u/Cafuzzler 10d ago

Backwards compatible is absolutely a strong argument against added comments. If you want a comment just do "comment":"whatever"

1

u/Batman_AoD 10d ago

json5 has this. 

1

u/Sightblinder4 10d ago

A , as an escape character in json seems like a bad idea, no?

2

u/da_Aresinger 10d ago

it's a blank space. Fill in whatever you think is best.

1

u/Batman_AoD 10d ago

The specific spec suggested is not good, but json5 does have very simple comments. 

2

u/slaymaker1907 10d ago

I think there's room for both JSONC and JSON, though I agree on keeping the base spec simple. Comments really aren't necessary for REST, but they are handy if you're using JSON for configuration. Personally, I think TOML is better for configs, but JSON+comments is probably way easier to implement.

Oh, and even besides complexity, I'm certain that adding in comments would hurt parsing performance which is very important for certain applications.

5

u/DT-Sodium 10d ago

I would have gone with allowing trailing commas.

2

u/nicki419 11d ago

"comment": "This is a comment"

Thank me later

2

u/Successful-Active-21 11d ago

json5 has comments, no ?

2

u/xavia91 11d ago

Wtf is up with all the json bashing and yaml glorification today??

2

u/R15H1_3 10d ago

Just use "_comment" keys like the rest of us suffering in silence.

2

u/No-Shape-2751 10d ago

I think it’s the right choice. JSON is for machine communication, if you could add comments some “genius” would start embedding directives or hints or something in them and basically fork the standard.

2

u/Minimum_Shirt_157 10d ago

You are looking for JSON5

2

u/Dee4WasTaken 10d ago

"comment":"lol"

2

u/za72 11d ago

This may come as a shock but that's what's documentation is for...

I said what I said!

2

u/hearthebell 11d ago

Let's standardize jsonc to the whole internet!

*Whole internet dies

2

u/jensalik 11d ago

You can't do that on my day off....

2

u/abednego-gomes 11d ago

For local configs, you just write comments like

// this is a comment

Then you read the file and have a parsing step line by line to strip out any lines starting with // before you do the JSON decode of the whole file.

1

u/amadiro_1 10d ago

Yeah you can also use regex to find and remove trailing commas before parsing. A standardized, agreed upon format would be nicer, but I'm sure there are already a bunch to choose from.

1

u/Benjamin_6848 11d ago

Why would the genie refuse‽ Comments in JSON could be really useful and a good idea!

1

u/EvenRefrigerator100 11d ago

Better be trailing commas

1

u/Digital_001 10d ago

"Good wish. You still have 3 wishes"

1

u/Optimal-Savings-4505 10d ago

I also stumbled across that limitation, and my solution was to simply add a comment property with a string holding the actual comment.

1

u/LatentShadow 10d ago

Json5 has comments you know...

1

u/dharknesss 10d ago

{"comment":"No."}

1

u/gerbosan 10d ago

Is devcontainer.json a JSON file? 😓

1

u/KronisLV 10d ago

JSON5: https://json5.org/

Genuinely nice and useful, if you want a format that's less machine-centric than regular JSON.

1

u/Ebuall 10d ago

Jsonc? Most tools already support comments.

1

u/da_Aresinger 10d ago

It is incredibly easy to add comments to any spec.

All you need is the comment sequence and a way to escape it.

It's not a big deal conceptually. But if you're gonna start sending commented Json to other people they'll be very confused.

1

u/jhggiiihbb 10d ago

It’s like no one read the original json spec where they say to run it through a preprocessor for comments.

1

u/CodingChris 10d ago

Or - just don't use json.

1

u/HarryTerraCode 10d ago

But I really want it, no comment in json is sometimes annoying.

1

u/TheZedrem 10d ago

ever heard of jsonc?

1

u/Dimencia 10d ago

Is this a bad language joke that I'm too visual studio to understand?

1

u/NullSmoke 10d ago

Easy, just add a custom way to handle json into your app, problem solved. Then you get to watch all other JSON parsers yell their lungs out for eternity, and your app is still fine 😊

1

u/Respaced 10d ago

Sjson has it.

https://pypi.org/project/SJSON/

Was created by Bitsquid, game engine. (Later Stingray)

1

u/Desperate-Tomatillo7 10d ago

VSCode told met that there is JSONC.

1

u/MACMAN2003 10d ago

The genie is a tyrant!

1

u/RandomiseUsr0 10d ago

“c”:”fill your boots”

1

u/JackNotOLantern 10d ago

Schema, lol

1

u/Direct-Quiet-5817 10d ago

See, 🧞 JSONC 🧞

1

u/joan_bdm 9d ago

hjson you mean?

1

u/ktka 8d ago

Json Dval is not happy.

1

u/p1neapple_1n_my_ass 8d ago

2 days ago, I found out that there are no comments in json files. 

1

u/kingslayerer 11d ago

Maybe you should start using json schemas. You lazy

-1

u/BadgerwithaPickaxe 10d ago

Ai is making you guys less creative, because I have been able to put comments in every single language and framework I've tried.

0

u/ryu____ 11d ago

Add whatever you want in random comment fields. Just don't parse it in any object

-3

u/frayien 11d ago

I've been putting comments in my JSONs since forever and never had any issue with any parser, what is this about ?

6

u/realmauer01 11d ago

Than the parser is very lenient or something? json is meant to be computer readable not human readable.

3

u/Kiroto50 11d ago

Json5 and some other json specs allow comments ... Also, spaces, indentation and line separators beg to differ

-1

u/necrophcodr 11d ago

json is terrible for computer readable. if that's the main goal, pick something that isn't awful. if the goal is readability, json is still not very good, so why use it?

2

u/DanTFM 10d ago

Yeah we use // Comments in our JSON configs all the time. .Net json parsers just have an ignore comments flag.

when you’re using JSON for transport, of course no comments.

https://learn.microsoft.com/en-us/dotnet/api/system.text.json.jsoncommenthandling?view=net-10.0#fields

1

u/TwinStickDad 11d ago

Depends on your parser and where you're defining your json. If you're just creating a JSON file then you should be getting errors because that's not valid JSON. There are other formats like jsonc which just strip the comment lines before parsing to JSON. Apparently the new standard will support comments. 

1

u/frayien 11d ago

Yeah, it seems I just got lucky and my use cases always silently use jsonc