this post was submitted on 30 Jun 2024
553 points (98.1% liked)

Programmer Humor

19817 readers
89 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 2 years 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
[–] bleistift2@sopuli.xyz 1 points 5 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

[–] Aux@lemmy.world 0 points 5 months ago (1 children)

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

[–] bleistift2@sopuli.xyz 0 points 5 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.

[–] Aux@lemmy.world 0 points 5 months ago

It's not up to me. Or you.