this post was submitted on 30 Jun 2024
281 points (94.9% liked)

Programmer Humor

18961 readers
1047 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. Two images of JSON, one is the empty object, one is an object in which the key name maps to the value null. Caption: “Corporate needs you to find the difference between this picture and this picture”

Panel 2. The Java backend dev answers, “They’re the same picture.”

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

It can, but especially during serialization Java sometimes adds null references to null values.

That's usually a mistake by the API designer and/or Java dev, but happens pretty often.

[–] [email protected] 3 points 1 month ago (12 children)

That’s the thing though, isn’t it? The devs on either side are entering into a contract (the API) that addresses this issue, even if by omission. Whoever breaks the contract must rightfully be ejected into the stratosphere.

[–] [email protected] 0 points 1 month ago (11 children)

That's exactly not the thing, because nobody broke the contract, they simply interpret it differently in details.

Having a null reference is perfectly valid json, as long as it's not explicitly prohibited. Null just says "nothing in here" and that's exactly what an omission also communicates.

The difference is just whether you treat implicit and explicit non-existence differently. And neither interpretation is wrong per contract.

[–] [email protected] 8 points 1 month ago

I think we’re fully in agreement here: if the API doesn’t specify how to handle null values, that omission means they’re perfectly valid and expected.

Imagine a delivery company’s van exploding if somebody attempts to ship an empty box. That would be a very poorly built van.

load more comments (10 replies)
load more comments (10 replies)
load more comments (10 replies)