this post was submitted on 30 Jun 2024
573 points (98.2% liked)

Programmer Humor

19725 readers
54 users here now

Welcome to Programmer Humor!

This is a place where you can post jokes, memes, humor, etc. related to programming!

For sharing awful code theres also Programming Horror.

Rules

founded 1 year ago
MODERATORS
 

Meme transcription:

Panel 1: Bilbo Baggins ponders, “After all… why should I care about the difference between int and String?

Panel 2: Bilbo Baggins is revealed to be an API developer. He continues, “JSON is always String, anyways…”

you are viewing a single comment's thread
view the rest of the comments
[–] [email protected] 1 points 4 months ago (1 children)

What makes you think so?

const bigJSON = '{"gross_gdp": 12345678901234567890}';
JSON.parse(bigJSON, (key, value, context) => {
  if (key === "gross_gdp") {
    // Ignore the value because it has already lost precision
    return BigInt(context.source);
  }
  return value;
});
> {gross_gdp: 12345678901234567890n}

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse

[–] [email protected] 0 points 4 months ago (1 children)

Because no one is using JSON.parse directly. Do you guys even code?

[–] [email protected] 0 points 4 months ago (1 children)

It’s neither JSON’s nor JavaScript’s fault that you don’t want to make a simple function call to properly deserialize the data.

[–] [email protected] 0 points 4 months ago

It's not up to me. Or you.