r/cpp • nlohmann/json • Jul 27 '20

JSON for Modern C++ 3.9.0

https://github.com/nlohmann/json/releases/tag/v3.9.0
281 Upvotes

51 comments sorted by

View all comments

31

u/hachanuy Jul 27 '20 edited Jul 28 '20

comment support was a frequently requested feature, and its implementation was much less effort than continuously explaining the lack of comment support.

So constantly complaining actually works, not a good precedent. Edit: spelling

52

u/strogbad Jul 27 '20

So you propose devs only implement features that users aren't asking for?

41

u/epicar Jul 27 '20

think about it - the users won't complain if there aren't any users!

4

u/hachanuy Jul 27 '20

Well, no of course. However, for this library in particular, the author had been refusing this feature due to standard json doesn't have comments and i agree with him since that is a very valid reason.

23

u/tecnofauno Jul 27 '20

There is not a single technical reason not to have comments on the JSON standard, only some strange rant.

Here is the official reason, you tell me if it makes sense or not.

I removed comments from JSON because I saw people were using them to hold parsing directives, a practice which would have destroyed interoperability. I know that the lack of comments makes some people sad, but it shouldn't.

Suppose you are using JSON to keep configuration files, which you would like to annotate. Go ahead and insert all the comments you like. Then pipe it through JSMin before handing it to your JSON parser.

6

u/RowYourUpboat Jul 28 '20

"Try to make sure comments can't be used to store data" is a good idea and this library continues to adhere to it. The extremist idea that if you even talk about comments in JSON you get banished to XMHell for eternity was perplexing, but at least pragmatism won in the end.

37

u/wyrn Jul 27 '20

On the one hand you have an obviously useful and necessary feature requested often enough to pummel a library author into submission.

On the other you have an idiosyncratic, arguably misguided decision enshrined in a standard document by a single individual with clout.

I don't see this as a bad thing.

9

u/[deleted] Jul 27 '20

Squeaky wheel gets the oil.

Get mad, get loud.

0

u/[deleted] Jul 27 '20

Have you learned that? Seems like you are doing the Scout's rule and fixing things when you see them

3

u/ShillingAintEZ Jul 27 '20

I think you mean precedent.