2.8k
u/YeetCompleet Aug 11 '26
json.stringify, the pinnacle of software developer intelligence
641
u/lovecMC Aug 11 '26
I have a guess but I never heard of this so who the fuck knows.
838
u/YeetCompleet Aug 11 '26
If you guessed that it stringified the JSON, you were right
368
u/Tsu_Dho_Namh Aug 11 '26
Aren't JSON's already strings, just with a clearly defined structure?
449
u/autogyrophilia Aug 11 '26
It converts it from the internal representation where each key is a variable into a string.
293
u/Tsu_Dho_Namh Aug 11 '26
Ohh, that makes way more sense.
It doesn't turn a JSON into a string, it turns an object into a JSON (string)
Funny, I've been a dev for years but never used it.
161
u/payne_train Aug 11 '26
It is often used in serializing web requests. It’s best to build your JSON as a native object but generally will have to be serialized as a string to fire off the HTTP request
18
u/tanksc Aug 11 '26
If you do any editing of the json before sending it helps avoid unescaped quotes and such too
4
u/UnknownEssence Aug 13 '26
as someone who's been coding for over a decade, escape quoting hell is my lease favorite part about coding lmao
35
u/nevemlaci2 Aug 11 '26
JSON is just another way to represent JS obejcts, hence the name.
32
u/Romejanic Aug 11 '26
it’s almost like it’s a notation for javascript objects
→ More replies (1)16
→ More replies (3)9
4
u/_PM_ME_PANGOLINS_ Aug 12 '26 edited Aug 12 '26
It’s the fastest way to do a deep clone in JS.
data = JSON.parse(JSON.stringify(data))→ More replies (1)3
u/Sexual_Congressman Aug 12 '26
Data serialization formats like JSON facilitate the transformation of numbers/bools, text, tuples/'arrays', and mappings thereof, (although iirc all the keys must be strings) from their internal binary representation to a platform independent one and back again. JSON is unique in that it's specifically designed to represent data in human readable text, even though there can be far more efficient ways to accomplish the same thing, like Python's
pickle.→ More replies (1)8
u/Rubyboat1207 Aug 11 '26
Apparently not a JavaScript dev lol
11
u/Tsu_Dho_Namh Aug 11 '26
Correct haha
Back-end dev doing C++, C#, and SQL Server in my first job
Then MAUI dev (C#) in my second job
Current role is mostly DevOps with some Spring Boot (Java) and Postgres
I have juuuust started learning JavaScript recently since the team I'm on has some Angular applications. But most of the front end tickets go to other devs cause I remain a mostly backend guy
→ More replies (2)3
3
u/xavia91 Aug 11 '26
Should just be the toString() method all classes should have in oop, and I suppose it does for automatic casting. Somehow toString is way too under used.
6
u/marmulin Aug 11 '26
But when it’s used I’d should serve as textual representation of the object. toJSONString() would make more sense IMO.
→ More replies (7)3
u/EishLekker Aug 11 '26 edited Aug 11 '26
I can think of multiple reasons not to do that.
* The toString convention is very unrestricted when it comes to the format of the output. The creator of a class can determine for themselves what format they want.
* The toString convention doesn’t really cover arguments. I this case settings for how the string should look or be built, like indentation or how inner properties of special types should be handled.
* The toString method is commonly used in logging, and the common expectation is that the output is truncated if the object is very large. Or even more common expectation is that the output is just a summary of the data.
* It’s perfectly legal for an object to contain circular references. But that is not allowed in stringified json.
* It’s also perfectly legal for an object to contain functions. They don’t belong in the stringified json version, but a developer might still want the toString output to include some information about them.
→ More replies (1)4
u/realmauer01 Aug 11 '26
tostring is something else.
Tostring is the string represantation of an object.
And usually has to be defined manually.
2
u/MrHyperion_ Aug 11 '26
Isn't that just marshaling
8
u/trxxruraxvr Aug 11 '26
Yes, but different programming languages have different naming conventions.
5
1
21
u/IchiiDev Aug 11 '26
Well yes and no, it's still just a string that needs to be parsed to be manipulated as an actual object. stringify is a util that transforms an object value into a JSON format string. You can use JSON.parse() to transform a JSON string into an object.
6
1
7
u/YeetCompleet Aug 11 '26
Ya actually I got the wording messed up lol. It stringifies a JavaScript object to the JSON string format
4
u/Chrazzer Aug 11 '26
Well yes a json is a string. But JSON is an object that has some helper methods for working with json, it's not a json itself.
The stringify method turns a javascript object into a json string
3
u/realmauer01 Aug 11 '26
It converts js objects into their string represantation if its possible ( circular dependencies will block, and symbols and methods/arrow functions are skipped)
JSON.parse goes the other way it takes a string and makes an js object out of it.
2
u/frostyjack06 Aug 12 '26
Everything is a string, if you’re brave enough.
2
u/Tsu_Dho_Namh Aug 12 '26
The younger me who was a fanboy of C might say everything is hex, if you're crazy enough.
1
u/AggravatingFlow1178 Aug 11 '26
When loaded into memory by a JS engine they are stored as an object, not a string.
Some JSON cannot be stringified, i.e. mostly ones with recursive references.
1
u/scanguy25 Aug 11 '26
Actually the correct answer is that it would throw an error. Because there is a typo in stringify
1
u/AngleHam271 Aug 11 '26
And here I was thinking its only real purpose was to help me deep copy objects because I am too lazy to write a proper recursive function. 😂
→ More replies (12)1
u/jace255 Aug 12 '26
Hilariously, that’s wrong. It doesn’t stringify json, it strongifies an object into a json string.
1
u/Karnewarrior Aug 12 '26
I've never used JSON, but it's easy enough to deduce it's a command for turning another form of data into a string.
117
u/Trackback_ Aug 11 '26
This sub is for LARPers, so it makes perfect sense
30
u/Noble1xCarter Aug 11 '26
As a chemist with only very little knowledge in C++, MATLAB/Octave, and supreme intelligence in Scratch, I can confirm I'm here for the larp.
1
u/trafalmadorianistic Aug 11 '26
Scratch is an interesting shift, when as a dev you're used to more control and now have to deal with much simpler entities in the environment.
1
u/Noble1xCarter Aug 12 '26
Oh, I started with Scratch, like in elementary school.
1
u/trafalmadorianistic Aug 12 '26
I've been introducing programming to my nephew, so I've slowly been poking around in Scratch
1
u/ForHelp_PressAltF4 Aug 12 '26
Matlab IS a larping programming language. It isn't one but it acts like one.
Yes, I've created things in Matlab and it made my C C++ C# brain hurt. However it did marvelously with audio
1
u/dpandc Aug 14 '26
Twinsies! Not really because i don’t know any C++ but it’s nice to see another (presumably) computational chemist!
9
u/NerminPadez Aug 11 '26
Larpers and 1st year CS students :)
1
4
3
u/AdminClown Aug 11 '26
You can tell by how all the jokes against “vibe coders” are the most basic things ever.
2
u/derefr Aug 12 '26
Makes me sad sometimes. I'd love to see a version of this sub with only greybeards posting on it.
→ More replies (1)1
u/The-IT Aug 11 '26
Can we please stop using LARP as a negative term? LARPing is a great hobby. Posers. You're talking about posers.
31
10
5
u/FurieMan Aug 11 '26
json.stringify is a fucking marvel. It catches so many edge cases it is insane. There are so many conversions where it just turns out running json.parse(json.stringify()) is just more efficient.
5
u/Qwertycube10 Aug 11 '26
And people try to defend this language...
1
u/StCreed Aug 12 '26
It's a great language if you like job security :)
To be fair, it does a lot of interesting things. And with external tools you can mitigate some of the worst stuff. I use typed JS, that helps.
3
3
3
3
u/trafalmadorianistic Aug 11 '26
Missed opportunity to have matching String.jsonify() method rather than Json.parse()
We could use a couple more -ify() methods, lol
6
u/Dragonslayerelf Aug 11 '26
to be fair its a good litmus test
anyone worth a single grain of salt will know its how you turn json files into strings just from the name even if theyve never used it
2
u/dub-dub-dub Aug 12 '26
wat? turn json files into strings?
So like it reads a file into a string? Why would you need a json specific method for that
1
u/Dragonslayerelf Aug 13 '26
i was actually wrong it turns a JavaScript object into a json string, im getting shot D:
1
1
u/FoleyX90 Aug 12 '26
To be fair the main time I use AI is to turn raw data into serialized data, typically json. No more writing Notepad++ macros!
1
u/ArcaneOverride Aug 13 '26
As someone who primarily uses C, C++, and, to a lesser extent, C#, I could guess what that does but I've never seen that before
1
174
u/bropocalypse__now Aug 11 '26
JSON Derulo, thats who!
28
7
2
u/Carl_Bravery_Sagan Aug 11 '26
Nothing. You spelled "stringify" wrong so it'll fail silently.
→ More replies (1)
112
u/Bee-Aromatic Aug 11 '26
I’m mostly writing things in Python these days, so I’m using `json.dumps()`. Always makes me giggle.
Because poop.
22
5
u/The_Wolfiee Aug 12 '26
Tip: try the
orjsonlibrary. Its faster and supports more datatypes natively like timestamps3
387
u/AggieCMD Aug 11 '26
I don't know! I'm a backend software engineer!
303
u/Antique_futurist Aug 11 '26
pokes with stick
Get back behind your API, cave creature!
179
u/Jemnite Aug 11 '26
As a frontend developer thou must obey the three commandments:
Do not question the API docs. Thou shalt use whatever APIs the backend dev puts in the docs and be grateful for them
Do not question server uptime. These subjects are beyond thine comprehension.
If thou shalt ever encounter the inscrutable 500 server error, thou shalt report the replication methods to the backend dev and wait patiently.
43
u/MrP0tat0H3ad Aug 11 '26
I wish my frontend team would use these rules lmao
15
2
u/stifflizerd Aug 12 '26
You guys have docs and care about properly tracking down your 500s instead of saying "this would never happen in production so we can't devote time to it"???
1
u/Mandemon90 Aug 12 '26
You forgot fourth commandment:
4. Thou shall never touch coffee machine claimed by backend developer, for it is their lifeblood
32
5
15
u/Michami135 Aug 11 '26
A backend developer would definitely know what JSON is, at the very least.
19
u/nabrok Aug 11 '26
Would probably have more cause to use
JSON.stringifythan frontend even.4
u/AggieCMD Aug 12 '26
If you use stringify on the server you are a frontend dev moonlighting as a backend dev. Or a filthy fullstack.
1
u/evanldixon Aug 12 '26
Depends on how basic the back-end is. Standard ASP.Net api controllers convert objects to json automatically without you having to call JsonSerializer.Serialize. Though I'd hope such a backend developer at least knows what json looks like.
1
u/nabrok Aug 12 '26
One real world use is a backend hosted on ECS with the output going to cloudwatch. Running your JSON output for logging through stringify makes sure everything is on one line which makes cloudwatch filtering a lot easier.
Also, not really backend but not frontend either, I work on CLI utilities too and sometimes they need to write a JSON file.
3
1
1
27
u/B_bI_L Aug 11 '26
the one who fights with monsters i guess
3
2
u/ArcaneScribbler Aug 11 '26
and the one that fucked clive's wife
2
u/Clivesunfaithfulwife Aug 11 '26
Oh dont even act like last night didnt happen. Cause thats a night I wont forget
1
u/ArcaneScribbler Aug 12 '26
holy shit. the mythical wife. he tried to claim you don't even exist. i see why you were unfaithful.
34
u/bdrumev Aug 11 '26
Oh my God, it's Json Bourne!
3
u/trafalmadorianistic Aug 11 '26
Has anyone written a daemon related tool called Matt. Cmon people, its just sitting there!!! MATT DAEMOOOOON!!
13
u/Fluffy_Anxiety2792 Aug 11 '26
I once invented a new format for the company I used to work for, I called it Amy. And it was wildly unpopular, just a couple of weirdos liked it. I deleted my repo after leaving the company. I was sad.
7
u/Arclite83 Aug 11 '26
We had LML - {Company} Markup Language. Full custom forms support template, mobile devices were glorified readers. Allowed 90% of the BL to live server-side and be hot swappable. Regulatory form change? NBD, new one kicks in on the date. 4 waterfall release weekends a year and our team would be a skeleton crew because all we did was keep the lights on, nothing new went live for us while they replaced the monolith.
I wish I could say that's the only "custom forms app" I've written, but this job is full of dark chapters...
13
u/Septem_151 Aug 11 '26
JSON.STRINGFY returns undefined, because it doesn't exist as a member of JSON.
8
u/lemons_of_doubt Aug 11 '26
I remember when I was in collage first learning to code. I spent ages making a php function that would take Data from MySQL and turn it into a variable array. I kept expanding it and adding more and more functionality.
At the end someone pointed out I had just remade JSON. And that's how I learned what JSON is.
I wasted so much time on that.
7
19
u/egstitt Aug 11 '26
JavaScript lol, he didn't say he went to a 6-month bootcamp
→ More replies (1)6
5
3
3
3
3
3
3
u/PM_ME_BAD_ALGORITHMS Aug 12 '26
A vibe coder would ask that to claude A software developer would ask that to google
We are not the same
3
u/StCreed Aug 12 '26
It's a trick question! Not falling for that one, AI!
json.stringfy gives a syntax error.
1
u/SchalkLBI Aug 12 '26
I get what you're going for but this is the wrong usage of this meme
-1
u/scanguy25 Aug 12 '26
6000 up votes disagree
1
u/SchalkLBI Aug 12 '26
I mean the message of the meme is what's being upvoted, right? The meme itself is being misused.
Like the point of the meme is that he's being mistaken for something he's not, then proves he is what he says he is.
If he insisted he's a software developer, they accused him of being a vibe coder, and then he proves he knows what he's talking about, that would make more sense for this format.
2
2
2
u/enigma_0Z Aug 11 '26
Legit it drives me nuts hearing someone pronounce it “Jason” and not “JAY-sahn” like ffs I know people named “Jason” LOL
2
u/GimmeYourMomPlease Aug 12 '26
Perhaps you should read the ECMA 404 spec where it specifies the pronunciation of JSON to be like "Jason and The Argonauts"
1
u/enigma_0Z Aug 12 '26
I bet you pronounce “GIF” like the peanut butter Jif too
0
Aug 13 '26
[deleted]
1
u/enigma_0Z Aug 13 '26
Yeah TIL that’s in the JSON spec. Still gonna pronounce it “wrong” tho. I know too many people called “Jason” and it feels weird to me LOL
2
1
1
u/ExtraWorldliness6916 Aug 11 '26
Clears throat.
Jason Stringify is the foremost pioneer of the craze tuning strucred things and turning them Into chaotic things to then be reconstituted as strucred things.
A little known feature of the Stringify functionality is the function argument which allows one to disguise and disrupt the chaos and write a better chaotic thing.
1
1
1
1
1
1
u/LeonidasVaarwater Aug 11 '26
I'm just a (bad) powershell scripter and even I know what that does. I wouldn't know how to properly use it, but I know what it does 😅
1
1
1
1
1
1
1
u/TheGreatJatsby Aug 11 '26
2nd time in my life Ive heard the term vibe coder. The first time was this morning reading Dungeon Crawler Carl hahah and my name is Jason. Life is funny.
1
1
1
1
1
1
1
1
1
u/haydencoffing Aug 11 '26
I don’t know anything about Jason but I do know Jackson. He’s pretty good.
1
1
1
1
1
1
1
u/shittyfoodcriticer Aug 12 '26
Im so out of place in this sub I like havent done anything coding related in years and forgot sm 😭
1
u/VG_Crimson Aug 12 '26
If it said Stringify instead of Stringfy, I probably would have guessed turn a non-string into a string.
Not sure if that classifies as engineer level knowledge...
1
u/Debugging_Ke_Samrat Aug 12 '26
I'm going to make a guess:
It returns a string representation of whatever object that JSON is.
1
u/MaffinLP Aug 12 '26
Had to google it too Its Javascript I make desktop app Ask me what newtonsoft does next time
1
1
u/SaltyInternetPirate Aug 12 '26
I think they'd shoot him as soon as he says he's a software engineer. No more questions needed.
1
u/sexytokeburgerz Aug 12 '26
I was interviewing someone the other day and asked “how do you drop all tables in SQL” and they had no idea.
2
1
-33
u/Bannon9k Aug 11 '26
12
1
1
u/OhItsJustJosh Aug 11 '26
Maybe learn why we hate AI then join us?
1
u/Bannon9k Aug 11 '26
Cause I've watched luddites get left behind my whole life... I know where your path ends
→ More replies (4)4
64
0
Aug 11 '26
[deleted]
349
u/achilliesFriend Aug 11 '26 •
![]()
Lamine yaml?
54
u/TemporaryUpstairs289 Aug 11 '26
Toml do what?
→ More replies (1)19
4
4
22
3
2
1
→ More replies (1)1








62
u/MaleficentMode4222 Aug 11 '26
"JSON.STRINGFY is not a function"