PHP and Node definitely do.
Node doesn’t.
> parseInt('077')
77
- If the input string, with leading whitespace and possible +/- signs removed, begins with 0x or 0X (a zero, followed by lowercase or uppercase X), radix is assumed to be 16 and the rest of the string is parsed as a hexadecimal number.
- If the input string begins with any other value, the radix is 10 (decimal).
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt
I’ve also never seen any piece of software that would treat a single leading zero as octal
I thought JavaScript did that, but it turns out it doesn’t. I thought Java did that, but it turns out it doesn’t. Python did it until version 2.7: https://docs.python.org/2.7/library/functions.html#int. C still does it: https://en.cppreference.com/w/c/string/byte/strtol
Darum geht’s nicht. Ich will Arbeits-Pizza.
JA ICH WEIẞ, DASS DAS DUMM IST.
ICH WILL PIZZA
Die Erklärung steht in der Pfosten-Beschreibung. Nach meinem initialen Schwall hat die Sache aber irgendwie ein Eigenleben entwickelt.
(Zangendeutsche jetzt wegsehen)
The explanation is in the post description. After my initial burst of memes, this topic seems to have taken on a life of its own…
I’m not sure if you’re getting it, so I’ll explain just in case.
In computer science a few conventions have emerged on how numbers should be interpreted, depending on how they start:
- decimal (the usual system with digits from 0 to 9): no prefix
- binary (digits 0 and 1): prefix
0b
, so0b1001110
- octal (digits 0 through 7): prefix
0
, so0116
- hexadecimal (digits 0 through 9 and then A through E): prefix
0x
, so0x8E
If your zip code starts with 9, it won’t be interpreted as octal. You’re fine.
Frankly that there isn’t a specific field signalling authorized/not-authorized
The instance I was bitching about was this: There’s a lot of region-specific data coming from the backend. But the user is only authorized for certain regions. So for instance the North-American guy gets this object: { "CA": [/* list of stuff */], "US": [/* list of stuff */], "MX": [ /* list of stuff */ ]}
, while the US-only guy only gets {"US": [ /* list of stuff */] }
. Are you suggesting that the response should also include flags isCaPresent
, isUsPresent
, isMxPresent
for every country?
The issue with null
vs not present surfaced because I, the frontend, checked if the returned object contained the key "CA"
and then tried to iterate over the list of stuff, which happened to be null, which is hard to iterate over. I agree that I could’ve checked if the key was present and not null.
The meme, however, was lamenting that the backend developer, refuses to acknowledge that these two JSONs are different,since they only see their POJOs, where both map to CA: null, US: [], MX: null
.
they also pay 3000$/mo for a moldy apartment
Somehow I can tell that this story didn’t go down in the US.
I wouldn’t have thought that content suitable for talesfromtechsupport would be acceptable here. As the description says,
This is a place where you can post jokes, memes, humor, etc. related to programming!
Customer support is not usually related to programming.
try to stick with integers in a currency’s smallest unit of division
And then the marketing department comes up with products that cost 1.5ct apiece.
Hell, no. If I wanted to save bytes, I’d use a binary format, or just fucking zip the JSON. Looking at a request-response pair and quickly understanding the transferred data is invaluable.
I’m sad that there are people who call themselves developers who need to be told this.
Both instances are legal serialized JSON. What makes you think otherwise?
So it sounds like an issue with […] handling per-spec the presence of data which you don’t use.
The trouble is, in this specific use case, the data may either be there or it may not be, depending on authorization. I’m checking specifically if the key is present to determine whether the user has access to that data (and display a toggle for that data), or if the user mustn’t see it and thus doesn’t need the toggle.
The wrong assumption was that if the key is there, then the value is not null. That assumption was invalidated by an update on the server side. Of course I could’ve checked if the value of the key is nullish. But it’s still annoying to have a breaking frontend because the backend changed how it serves its data.
Und er hat Corona nicht direkt in der Küche eingespannt? Nett von ihm.
I refuse to validate data that comes from the backend I specifically develop against.
Or even funnier: It gets parsed in octal, which does yield a valid zip code. Good luck finding that.
Holy shit, I’m sorry.
Though I once proposed an API like that for user preferences. I just needed “someone” (that wasn’t the client) to store a bunch of data for me. The backend doesn’t interpret it, the backend doesn’t edit it, so why should they deserialize and serialize it again? Just give it to me when I ask for it, kay?
![the background blur](https://sopuli.xyz/pictrs/image/f4615c71-f99b-4a16-b225-cc4146103316.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/f4615c71-f99b-4a16-b225-cc4146103316.webp?thumbnail=1024&format=webp)
Auf der Arbeit habe ich viele Pizza-Michmichs pfostiert. Deshalb hat mein Kollege dieses Michmich erstellt.
![the background blur](https://sopuli.xyz/pictrs/image/ae43faa2-7072-4d22-b9cd-69e3d5a93a33.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/ae43faa2-7072-4d22-b9cd-69e3d5a93a33.webp?thumbnail=1024&format=webp)
Auf der Arbeit habe ich viele Pizza-Michmichs pfostiert. Deshalb hat mein Kollege dieses Michmich erstellt.
![the background blur](https://sopuli.xyz/pictrs/image/7087a017-c310-40cc-92b9-a186e28b1c51.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/7087a017-c310-40cc-92b9-a186e28b1c51.webp?thumbnail=1024&format=webp)
Auf der Arbeit habe ich viele Pizza-Michmichs pfostiert. Deshalb hat mein Kollege dieses Michmich erstellt. (Er benutzte die Un-Sprache)
I think that’s too short-sighted. I remember reading The Great Gatsby and I didn’t like it, because it was so hard to decipher. That leads to either reading it only superficially or not at all. How does that help teen literacy?
If you want to increase teen literacy, give them something to read that they actually enjoy or care about. High-society of (literally) a hundred years ago doesn’t help.
![the background blur](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=1024&format=webp)
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…”
![the background blur](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=1024&format=webp)
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…”
![the background blur](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/15dcbd6e-ee52-4ecc-bd3b-5f760e4ba844.webp?thumbnail=1024&format=webp)
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…”
![the background blur](https://sopuli.xyz/pictrs/image/9d235457-065f-4844-9828-982ca24d455a.webp?thumbnail=256&format=webp)
![](https://sopuli.xyz/pictrs/image/9d235457-065f-4844-9828-982ca24d455a.webp?thumbnail=1024&format=webp)
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.”