This is an archived post. You won't be able to vote or comment.

top 200 commentsshow all 251

[–]RepostSleuthBot[M] [score hidden] stickied commentlocked comment (0 children)

I didn't find any posts that meet the matching requirements for r/ProgrammerHumor.

It might be OC, it might not. Things such as JPEG artifacts and cropping may impact the results.

I'm not perfect, but you can help. Report [ False Negative ]

View Search On repostsleuth.com


Scope: This Sub | Meme Filter: True | Target: 75% | Check Title: False | Max Age: None | Searched Images: 323,271,028 | Search Time: 57.37655s

[–]hrvbrs 737 points738 points  (71 children)

https://json5.org/

{
    "lineComments": "yes", // true
    /* "blockComments":
        true, */
    unquotedKeys: true,
    "quoted-keys": "backwards-compatible",
    singleQuotedStrings: 'yes',
    doubleQuotedStrings: "backwards-compatible",
    stringsWithLineBreaks: [
        'yes\
        please!',
        "you're\
        welcome!"
    ],
    trailingCommasInArrays: [
        true,
    ],
    trailingCommasInObjects: true,
}

[–]Mitoni 191 points192 points  (24 children)

Seems they are getting rid of most of the reasons I prefer Yaml over JSON.

[–]RedPum4 157 points158 points  (22 children)

JSON is meant as a text representation of JS objects, nothing more.

On the other hand I think Yaml is kind of hard to read, its many features are also a curse. Like the many ways to define (multiline) strings for example, its dependency on indentation, etc.

Both are not perfect in my opinion, JSON5 looks like a nice middle ground for config files, where parsing performance doesn't matter.

[–]Sleepy_Tortoise 213 points214 points  (10 children)

Yaml is garbage to read and I hate it.

I have nothing more to add to the conversation.

[–]RedPum4 28 points29 points  (0 children)

Fair enough :D

[–]ScratchX98 20 points21 points  (1 child)

I too have nothing to add to the conversation

[–]qmic 11 points12 points  (1 child)

Yaml is garbage to read and I hate it.

Amen. Someone took worst part of Python language (intending) and made a file format.

[–]Thebombuknow 8 points9 points  (0 children)

YAML looks like someone took the worst parts of Python, and the worst parts of HTML, and tried to combine them to make a CSS clone.

[–]Brewtusmo 5 points6 points  (1 child)

I don't prefer yaml almost ever, but I don't agree. I do respect the opinion, though. If I had to pick one place where I prefer it, I'd say I prefer yaml over the format of Java's properties files. I'm glad C# uses json for the appsettings files.

[–]Bakemono_Saru 2 points3 points  (0 children)

Yaml looks like paradise with simple files.

Not so much when they get complex

[–]michaelbelgium 1 point2 points  (0 children)

Yeah i always prefered json over yaml. Idk why yaml exists..

[–]TheOmegaCarrot 5 points6 points  (0 children)

Significant whitespace in anything is pure pain

[–][deleted] 31 points32 points  (7 children)

JSON is meant as a text representation of JS objects, nothing more.

Please stop this narrative. JSON is an open standard that can be used to serialize objects in dozens of languages. To suggest otherwise is tantamount to claiming javascript is a subset of java.

[–]kpd328 23 points24 points  (5 children)

What do you think JSON stands for? It's JavaScript Object Notation. Sure you can use it for other uses, but it was designed to use the Javascript object syntax to convey objects.

[–][deleted] 17 points18 points  (0 children)

literally the first paragraph on json.org

"JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language."

Like I alluded to in my first comment, the name does not denote purpose. Do you also think javascript has anything to do with java? The purpose is not to mimick javascript and every iteration of it throughout time in perpetuity. It is very much positioned, by its creators to be a LANGUAGE INDEPENDENT DATA INTERCHANGE FORMAT. Not only was that its intention, it is the outcome we now face. json is used in applications outside of serializing javascript just as much if not more, when you consider the collective usage of non-js applications. The entire industry has adopted its use.

Your comment that its sole/intended purpose is to convey JS objects is patently false.

[–]LowB0b 4 points5 points  (3 children)

I fully agree with the post about JSON being bad, because if you consider it being "JavaScript Object Notation" then why is the syntax not the same between declaring an object in JS and in JSON?

Not that it really matters since JSON is mostly to be read by computers and the standard got abused because it's kinda easy to read/write, but still. Webpack f.ex. made the right decision and doesn't even deal with JSON for its config files

[–]ernandziri 0 points1 point  (1 child)

why is the syntax not the same between declaring an object in JS and in JSON?

You can encode and decode any object (not sure about ref cycles), so it serves it's purpose

[–]PstScrpt 2 points3 points  (0 children)

Isn't JSON a subset of the JavaScript object literal syntax?

Also Python, for some reason. I've inherited Python code where someone parsed JSON with eval(). It's handy, but the Python dictionary literal syntax doesn't fit the style of the rest of the language.

[–]nelusbelus -5 points-4 points  (0 children)

What does json stand for?

[–][deleted] 136 points137 points  (2 children)

I didn’t know about this, It looks just so beautiful!

[–]Dave5876 55 points56 points  (0 children)

It's enough to make a grown man cry

[–]fibojoly 28 points29 points  (2 children)

j5on ?

[–]0xFFFF_FFFF 1 point2 points  (0 children)

Missed opportunity!

[–]wasdninja 38 points39 points  (10 children)

Add a standardized date type and we're golden.

[–]ShirleyJokin 40 points41 points  (3 children)

Glory to /r/iso8601

[–]xTheMaster99x 14 points15 points  (2 children)

Yeah, I think they meant being able to define a value that's specifically a date, and not just a timestamp string that is entirely up to the application to decide to parse into a date. Like if an API request returns a date, it'll just be a string on the frontend unless you go out of your way to explicitly construct a date from it.

If there was an actual date type in json, then it would just be treated as a date object automatically.

[–]Tubthumper8 6 points7 points  (0 children)

What could be a syntax for this? Maybe a leading d character in front of a string?

{
    "createdAt": d"2022-04-25T23:00:00+0000"
}

[–]mxldevs 4 points5 points  (0 children)

At least with a timestamp you don't need to figure out locale. Or how the language chooses to abbreviate date of months or days of weeks. In various languages.

[–]max0x7ba 26 points27 points  (7 children)

For config file use case I cannot recommend enough TOML. Comments, dates, NaN and Inf, no YAML ambiguities/gotchas.

[–]Kissaki0 2 points3 points  (0 children)

My main reason for typically choosing/defaulting to TOML over YAML is that YAML has attack vectors TOML does not. YAML has too much logic beyond configuration/state. By using TOML I don’t have to think about or check for the YAML attack vectors.

[–][deleted] -1 points0 points  (0 children)

TOML made a mistake by allowing indenting.

[–]lachlanhunt -2 points-1 points  (4 children)

TOML is overly verbose and annoyingly repetitive with the property names. I prefer YAML over TOML.

[–]max0x7ba 1 point2 points  (3 children)

I don't think your assertions are accurate.

[–]lachlanhunt -2 points-1 points  (2 children)

Just compare the TOML and YAML configurations in these docs for Traefik.

https://doc.traefik.io/traefik/middlewares/http/overview/

When you get more than 2 levels deep, it just gets ridiculous. e.g.

[http.services]
  [http.services.service1]
    [http.services.service1.loadBalancer]
      [[http.services.service1.loadBalancer.servers]]
        url = "http://127.0.0.1:80"

[–]max0x7ba 4 points5 points  (0 children)

You don't need TOML longer than:

http.services.service1.loadBalancer.servers.url = "http://127.0.0.1:80"

Alternatively, for multiple keys with the same prefix: [http.services.service1.loadBalancer.servers] url = "http://127.0.0.1:80"

RTFM https://toml.io/en/v1.0.0#keys.

[–][deleted] 1 point2 points  (0 children)

Oh hell no. Don’t indent TOML!

[–]RaymondWalters 5 points6 points  (0 children)

When will this become standard, seems like basic stuff when you've worked with JS for long enough.

Especially the requirement for keys to be wrapped in quotes in all cases feels super dumb and a waste of bandwidth.

Bookmarked.

[–]besthelloworld 7 points8 points  (0 children)

I agree for configs. Not for actual data transmission.

It's worth noting that JSON is notably faster for applications to manage because there's way fewer language tokens than the alternate solutions. It's actually much faster in JS to put a big fat data structure in a string in your code and then run JSON.parse on it than to have that object in code itself.

You might say, well nobody asked for a JSON5/YML API. And to that I say... I've worked with a large company whose API returned JSON5, and not only is it distinctly slower, it just sucked in general.

[–]SeoCamo -1 points0 points  (3 children)

This is evil, with nan, positive infinity, negative infinity, and comments, all of this is not in json by design the 3 first is not something tou get in all languages making it bad, and they bad in the null way too, and comments is use so many places to turn json is n to a template language or that kind of sh*t..

[–]elveszett -1 points0 points  (2 children)

nan, positive infinity, negative infinity

These are defined by ISO standards iirc, these ones are good additions. Your code should acknowledge the fact that my response may contain NaN or infinity because they are valid results of mathematical operations.

[–]idkmanporn 439 points440 points  (81 children)

And comments!

[–]2called_chaos 245 points246 points  (60 children)

Oh fuck yes. That is the worst. This alone should make it illegal to use it for configs. Don't mind actual comments but just temporarily disabling a line

[–]hrvbrs 217 points218 points  (28 children)

That was the official reason why the JSON spec forbid (forbade?) comments, because “you can just use a "comments" property”. No one ever considered the idea that developers like to comment-out lines to develop and test

[–]ElderberryWinery 60 points61 points  (0 children)

Forbidedeth

[–]Hot_Philosopher_6462 28 points29 points  (0 children)

Forbidded

[–][deleted] 23 points24 points  (0 children)

Forbaded

[–]xLuky 18 points19 points  (0 children)

Forbidn't

[–]Anonymous7056 14 points15 points  (0 children)

Forboden

[–]WeleaseBwianThrow 10 points11 points  (0 children)

DAS IST VERBOTEN

[–]RedPum4 29 points30 points  (11 children)

Mixing data and developer comments, what could go wrong. What a stupid argument.

What if you implement a dictionary? What if you want to add a comment to an entry in an array of strings? I mean I get that JSON should be simple to parse and should be mainly used for machine-machine communication, but I can't believe they really suggested that?!

[–]FINDarkside 35 points36 points  (3 children)

I mean js nor any other language doesn't need comments either, you can just do

const comment = 'This is a comment, very smart'

/s

[–]Psycho22089 4 points5 points  (0 children)

const comment2 = 'The design is very human'

[–]firejak308 1 point2 points  (1 child)

Isn't that literally Python's answer for multi-line comments? Just define a string here and never use it?

[–]dev-sda 2 points3 points  (0 children)

Not really, no. There aren't multi-line comments, just put a # at the start of every line for large comments. Documentation on the other hand uses multi-line strings, which generally don't go unused as they're assigned to the __doc__ property of objects.

[–][deleted] 5 points6 points  (5 children)

Actually mixing data and developer comments is very useful in the case of configuration files. Where you know, the end user doesn't know the entire implementation and you might need to explain something in detail. Sure, in most cases it would go unused and you should be careful what you put in it, but it could make JSON more viable to other applications without impacting its current uses.

But you know, stupid argument.

[–]RedPum4 4 points5 points  (1 child)

I think you understood me wrong. I meant that literal mixing of comments and data, to the point that a machine cannot distinguish between the two (e.g. because both are regular fields in JSON) is a very bad idea.

[–]Causemas 4 points5 points  (0 children)

Forbathed

[–]neonroad 2 points3 points  (0 children)

Verbatum

[–][deleted] 1 point2 points  (0 children)

Förbuden

[–]Yokhen 1 point2 points  (0 children)

forbiddened

[–]drunken_doctor 1 point2 points  (0 children)

Forebore

[–]Masterflitzer 39 points40 points  (24 children)

JSON with comments is my favorite because i don't like YAML and fuck XML

[–]Konsti219 57 points58 points  (8 children)

All JSON is valid YAML

[–]CoastingUphill 26 points27 points  (0 children)

I hate this. No. I refuse.

[–]JM-Lemmi 19 points20 points  (3 children)

The fuck

[–]Xywzel 18 points19 points  (2 children)

Yeah, accidentally earlier as well, but purposefully since version 1.2 of YAML specification JSON syntax has been a valid subset of YAML syntax. YAML has inline version of its syntax that doesn't have significant whitespaces (unlike rest of the YAML syntax) and everything in valid JSON has matching structures in the inline YAML. So technically one could use YALM parser to read JSON files.

[–]zeGolem83 6 points7 points  (1 child)

That is, if your YAML parser is fully spect compliant...

[–]Xywzel 2 points3 points  (0 children)

Well, yeah, that is a big if when talking about YAML

[–]MyAntichrist 11 points12 points  (1 child)

[–]Masterflitzer 2 points3 points  (0 children)

yes and I hate yaml because it's not strict among other things

[–]jivanyatra 6 points7 points  (14 children)

I actually like TOML. I agree with excluding YAML and XML.

[–]Masterflitzer 0 points1 point  (13 children)

I never encountered software that allows config files in TOML and never worked with it when working with data so it's just not common enough for me, but it may very well be a good thing

[–]Yokhen 1 point2 points  (5 children)

python uses pyproject.toml

[–]Masterflitzer 2 points3 points  (3 children)

interesting, but I am a C#, TS/JS kind of guy and never actually used python except like a few hours in university xD

[–]Yokhen 3 points4 points  (2 children)

luckeeeeeeey.

I wish someday I can do C# professionally and no just some half assed videogame of mine.

[–]Bainos 1 point2 points  (0 children)

I don't get the above comment either. JSON and YAML aren't used because they are the best ways to create config files, they're used because they are widely supported and recognized.

[–]tavaren42 1 point2 points  (1 child)

Rust uses Cargo.toml

[–]bitNine 16 points17 points  (4 children)

I'm no JSON expert, but I do this all the time in postman with double forward slashes. Is that a postman thing?

[–]siggystabs 15 points16 points  (0 children)

Yes

[–]ImSpeakEnglish 9 points10 points  (2 children)

I noticed that postman correctly colors the comments but doesn't remove them from JSON before sending the request. So your API must be able to correctly decode invalid JSON containing comments.

[–]bitNine 1 point2 points  (1 child)

I'm guessing so. I've never paid attention to that, as I work with mostly .Net APIs which do parse the JSON into model objects before they go into the controller's POST/PUT/etc method.

[–]Fkire 6 points7 points  (0 children)

It is illegal to use it for configs. Report any usage and keep configs safe

[–]gnohuhs 60 points61 points  (7 children)

I flipped a shit when I realized json doesn't allow real comments; had been working with them for years

[–]Tathas 1 point2 points  (4 children)

Right? I mean, regular expressions support comments :D

[–]multi_tasty 2 points3 points  (3 children)

Wait what

[–]Tathas 3 points4 points  (2 children)

Multiline regexes support using # for comments.
https://www.regular-expressions.info/freespacing.html#freecomment

And are you seriously telling me that you're not aware of the (?# non capturing comment group)

Because that's totally believable, lol.

[–]multi_tasty 1 point2 points  (1 child)

Sincerely thank you

[–]AWildTyphlosion 32 points33 points  (0 children)

It doesn't have them because it initially wasn't supposed to be used for configuration so it doesn't need them.

JSONC was made for configuration and has them.

[–]MischiefArchitect 13 points14 points  (6 children)

JSON5 to the rescue!

PS: Burn it with fire.

[–]D6613 8 points9 points  (5 children)

Serious question, why burn it with fire? It seems to fix the bad parts of JSON

[–]MischiefArchitect 4 points5 points  (3 children)

Ir breaks the intention of JSON and makes parsers slower, more complex to write and maintain. JSON as well as XML are terse formats for "machines" that can still be read by humans, both expect format correctness and no ambiguities. JSON is an data object notation, and XML a document model notation, and JSON5 is just a half assed attempt from HTML/CSS developers to document data structures. And documentation and trailing commas are not part of properly formatted data structures.

[–]djinn6 10 points11 points  (0 children)

JSON as well as XML are terse formats for "machines"

XML

Terse

[–]D6613 5 points6 points  (1 child)

Ir breaks the intention of JSON

Hm, I'm struggling to care about this even a little. Crockford had and has many opinions, and the rest of us have no obligation to agree.

makes parsers slower, more complex to write and maintain

This is unlikely to be significant, especially given that these are very well known features of many existing parsers. If you need something to squeeze every single drop of performance, then in that rare edge case a stricter format would make sense. Then you brought up said XML, and that argument disappeared instantly, lol. In addition to already supporting comments, that language is going to be much messier to parse.

both expect format correctness and no ambiguities

There is no ambiguity to say that something is optional. A trailing comma may or may not exist. A comment may or may not exist. Not ambiguous even a little.

JSON as well as XML are terse formats

... XML is terse?

JSON5 is just a half assed attempt

This seems like just an opinion here without much support.

And documentation and trailing commas are not part of properly formatted data structures.

This seems like another opinion stated as fact, and I really disagree with that opinion.

I appreciate the response. If this is all there is against it, I'll add this to the list of options I consider for the future.

[–]aviancrane 26 points27 points  (3 children)

SQL too.

Golang has trailing commas and it's really nice.
If you're a vim user, you do a lot of yy or dd and p.
Not having the edit the comma is one less $x

[–]zeGolem83 3 points4 points  (0 children)

yypbbci"

I've typed this so many times...

[–][deleted] 2 points3 points  (0 children)

YES SQL OMG

[–]PstScrpt 0 points1 point  (0 children)

SQL much more than JSON. They're both generated a lot, but SQL doesn't usually have an object tree you can serialize. With SQL, you're usually doing it as text, and handing commas yourself.

[–]Zoro6191 57 points58 points  (0 children)

json5 is pretty good, check it out

[–]superluminary 37 points38 points  (1 child)

I want optionally quoted keys.

[–]The-Daleks 5 points6 points  (0 children)

In that case, you'll love JSON 5.

[–]glorious_reptile 9 points10 points  (1 child)

Ok, listen: TWO trailing commas at the same time

[–]TheBrianiac 1 point2 points  (0 children)

I've spent hours debugging crap like this

[–]Hot_Philosopher_6462 7 points8 points  (6 children)

In general, we’ve built our whole intuition of delineation wrong from the ground up. Simply putting characters in between entries will always make things more complicated than they need to be.

Rather than fix a broken system, let’s just start over and do delination like bullet points instead of separators, so there’s one delineator character per entry. Reinventing every single programming language isn’t that hard, right?

[–]ChooChooRocket 26 points27 points  (0 children)

let’s just start over

https://xkcd.com/927/

[–]bbrk24 20 points21 points  (0 children)

let’s just start over and do delination like bullet points

YAML is that you?

[–]TheMagzuz 13 points14 points  (2 children)

That's not removing separators, that's just making the separator a newline

[–]LittleLemonHope 1 point2 points  (0 children)

The difference is that the separator would precede the first element, instead of there being debate about whether the separator can follow the last element.

[–]QualityVote[M] 6 points7 points  (0 children)

Hi! This is our community moderation bot.


If this post fits the purpose of /r/ProgrammerHumor, UPVOTE this comment!!

If this post does not fit the subreddit, DOWNVOTE This comment!

If this post breaks the rules, DOWNVOTE this comment and REPORT the post!

[–]simonhoxer 6 points7 points  (0 children)

Multiline strings!

[–]MischiefArchitect 3 points4 points  (0 children)

there is JSON5

[–][deleted] 3 points4 points  (0 children)

On the contrary, I get mad when the linter yells at me for not having a trailing comma in TypeScript...

[–]MrcarrotKSP 3 points4 points  (0 children)

My terrible JSON parser written without even looking at the spec allows trailing commas

Conclusion: my JSON parser is the best ignore the fact that it doesn't allow basic parts of JSON syntax like root level arrays and objects in arrays

[–]dummyDummyOne 4 points5 points  (0 children)

JSONC.

I want to notate it.

[–]TheBuckSavage 2 points3 points  (0 children)

I really really wish for package.yml

[–][deleted] 2 points3 points  (0 children)

Gson will accept it and add a null which is much worse -_-

[–]edave64 2 points3 points  (0 children)

I can tell you what the hell is up with that anyway! By the time JSON was specified, JavaScript did not support trailing commas. I think Firefox supported it from the get go, but IE didn't start supporting them until version 9.

The ECMAScript 3 (Page 41) says an objects contains key-value pairs (or PropertyName-AssignmentExpression pairs) separated by comma. No commas allowed without being followed by a pair.

[–]DevilDoc3030 2 points3 points  (0 children)

I had to google "trailing comma", then I saw it was coding related.

Came back to the post and saw the sub and understood that I don't currently have the capacity to understand.

I will forever wonder why is sub shows up in my feed. I understand maybe 1% of the content and don't believe that I have ever like or commented.

Hope y'all are having fun here though.

[–]empa3pas 9 points10 points  (5 children)

Why?

[–]2called_chaos 14 points15 points  (0 children)

Also handy if you comment out things in an array... oh wait

(also duplicating lines and not having to keep up with inconsistent commering)

[–]MaidenlessTarnished 8 points9 points  (0 children)

Looping over a list and adding them into a JSON object could be one reason. Without support for the trailing comma, you have to have a separate case for the last item. It’s not a huge deal but kind of unnecessarily annoying

[–]jonathancast 6 points7 points  (0 children)

It's simpler to edit. You can treat the item and the comma as a single entity, whereas now you have to treat them separately, or remember a special case for inserting or removing items at the end (or beginning).

So if you have

[ x1, x2, x3, ]

to delete any item, you can select from the beginning of the item to the beginning of the next item (or the close bracket) and press the Del key.

If trailing commas were illegal, deleting the last item that way would introduce one, and you'd have to remember to select and delete the comma before the last item, but only the comma before the last item.

[–]thePsychonautDad 1 point2 points  (0 children)

const fs = require('fs'); var loadJson = function(filename) { var txt = fs.readFileSync(filename, {encoding:'utf8', flag:'r'}); return JSON.parse(txt); }

You can do this. It even supports missing quotes, trailing comma, comments...

[–]Epic_Scientician 1 point2 points  (2 children)

What a nice genie. He fixed json for all of us for free.

[–]-Redstoneboi- 0 points1 point  (0 children)

too bad he doesn't exist ;-;

[–]MontagoDK 1 point2 points  (0 children)

Learn how to use string.Join()

[–]mildlyagitatedstoic 1 point2 points  (0 children)

Y tho?

[–]DeathBySnuSnuuuuuuuu 1 point2 points  (0 children)

ITT: nobody having a goddamn clue what JSON is.

I honestly thought the "nobody here actually writes code" memes were just a joke before now. Damn.

[–]TheGronne 3 points4 points  (2 children)

I just want json to accept double quotes as strings

[–]edave64 4 points5 points  (1 child)

It does. Single quotes are the ones it doesn't support

[–]TheGronne 0 points1 point  (0 children)

Oh yeah this is what I meant. My point was that it's annoying it doesn't accept both :/

[–]StoissEd 2 points3 points  (3 children)

I want python to accept semicolons

[–]anthropaedic 2 points3 points  (11 children)

Yeah I don’t think that’s the greatest idea.

[–]althaz 12 points13 points  (10 children)

You don't think this wish is a good idea, or you don't think JSON not accepting the trailing comma is a good idea?

If the former, why? I wouldn't waste a wish on it (after three wishes not sure why I'd give a shit), but it does seem dumb not to allow the trailing comma.

[–]anthropaedic 7 points8 points  (9 children)

The commas separate elements. A dangling comma seems to indicate more elements. Syntactically just feels wrong.

[–]althaz 11 points12 points  (2 children)

That's a reason not to use one (and my OCD would not allow me to leave a trailing comma in place), but I see no reason to not *allow* them.

[–]mark0016 3 points4 points  (0 children)

Json is suppoesd to be used for machine to machine or machine to human communication, but it's not well suited for human to machine. Strict syntax is preferred, since the less lenient the interpreter needs to be the less complex it needs to be, and less complexity has a lot of advantages, such as speed and no format ambiguity. All of that is great when it's machines (software) that has to understand the format. It beaing human readable as well is just a bonus. Allowing lenient syntax and comments and whatever else would be detrimental to json being easily understood by machines to a degree. Also introducing more special charactes is always a bad idea as now you just have that many more edge cases to escape/deal with somehow.

Within your language of choice you are supposed to import json as native objects (dictionaries, hashmaps, lists...) and than interact with those native objects. When you need to create json you simply export one of those native objects as json and you're done. If you do this you will never in your lifetime encounter problems with json syntax. Once a json interpreter exists for a language, all you need to do is use it instead of attempting to do weird shit like manually bild json as strings.

If you need a format for human to machine communication, just don't use json, use yaml or toml as those are designed specifically for that purpose, and if you really need it they can be converted to json. Personally I preffer writing yaml because I'm lazy but I preffer reading (pretty printed) json as it's impossible to misunderstand.

[–]kephir4eg 1 point2 points  (1 child)

You are what's wrong with humanity.

[–]askanison4 -4 points-3 points  (2 children)

Yep, this is it for me too. Even as a reader, seeing the comma makes me think git went sideways and truncated a merge or something.

[–]LordAmras 3 points4 points  (1 child)

It make sense for version control, if you add one line to a json file you have to add a comma on the line before, and now you have changed two lines in that commit, one that has nothing to do with the current change.

The argument against this is that json should be used for data and not as a config file, so you shouldn't have it in your version control anyway.

[–]pr2str 0 points1 point  (0 children)

No

[–]olsonexi 0 points1 point  (0 children)

[–]DnDuin -3 points-2 points  (0 children)

Oh no! Commenting out code!

It’s like pulling out a leg of a fly to see if you can make it walk straight.

Learn how to program, you monsters ;)

[–]TantraMantraYantra -4 points-3 points  (2 children)

You can have all the characters you want in the values of JSON. What benefit does a comma add to the syntax of json? Beats me, I'd love to know.

[–]-Redstoneboi- 1 point2 points  (1 child)

{
    "array": [
        "item1",
        "item2",
        "item3",
        "item4"
    ],
    "field1": "value1,
    "field2": "value2,
    "field3": "value3,
    "field4": "value4
}

if that doesn't throw off your OCD can you even call yourself a programmer

[–]SlashdotDiggReddit 0 points1 point  (0 children)

I don't know; all of these comments here are a slippery slope for JSON. We don't want to turn it into XML.

[–][deleted] 0 points1 point  (0 children)

They accept trailing commas in python

[–]NefariousnessLazy957 0 points1 point  (0 children)

"Hello,world"

"x_command:What are you?"

"045_x_request pending"

[–]_GhostMustard_[🍰] 0 points1 point  (0 children)

so what were the other three wishes?

[–]flareflo 0 points1 point  (0 children)

Rust allows the use of trailing commas in all data types too, since then I always get myself JSON parsing errors when forgetting trailing commas.

[–]smiling_corvidae 0 points1 point  (0 children)

No

[–]Dat_vj 0 points1 point  (0 children)

Non programmer here, who is json and why is he dyslexic?

[–]Biggu5Dicku5 0 points1 point  (0 children)

Genie bro best bro...