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.”

  • AggressivelyPassive@feddit.de
    link
    fedilink
    arrow-up
    3
    ·
    2 days ago

    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.

    • MostlyBlindGamer@rblind.com
      link
      fedilink
      English
      arrow-up
      3
      ·
      2 days ago

      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.

      • AggressivelyPassive@feddit.de
        link
        fedilink
        arrow-up
        2
        arrow-down
        2
        ·
        2 days ago

        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.

        • masterspace@lemmy.ca
          link
          fedilink
          English
          arrow-up
          4
          arrow-down
          2
          ·
          1 day ago

          Null means I’m telling you it’s null.

          Omission means it’s not there and I’m not telling you anything about it.

          There is a world of difference between those two statements. It’s the difference between telling someone you’re single or just sitting there and saying nothing.

          • AggressivelyPassive@feddit.de
            link
            fedilink
            arrow-up
            1
            arrow-down
            3
            ·
            24 hours ago

            Nope.

            If there’s a clear definition that there can be something, implicit and explicit omission are equivalent. And that’s exactly the case we’re talking about here.

            • masterspace@lemmy.ca
              link
              fedilink
              English
              arrow-up
              2
              arrow-down
              1
              ·
              edit-2
              19 hours ago

              Sure, in a specific scenario where you decide they’re equivalent they are, congratulations. They’re not generally.

              • AggressivelyPassive@feddit.de
                link
                fedilink
                arrow-up
                1
                arrow-down
                2
                ·
                23 hours ago

                Did you read the comments above?

                You can’t just ignore context and proclaim some universal truth, which just happens to be your opinion.

                • Doc Avid Mornington@midwest.social
                  link
                  fedilink
                  English
                  arrow-up
                  4
                  arrow-down
                  1
                  ·
                  21 hours ago

                  At the (SQL) database level, if you are using null in any sane way, it means “this value exists but is unknown”. Conflating that with “this value does not exist” is very dangerous. JavaScript, the closest thing there is to a reference implementation for json serialization, drops attributes set to undefined, but preserves null. You seem to be insisting that null only means “explicit omission”, but that isn’t the case. Null means a variety of subtly different things in different contexts. It’s perfectly fine to explicitly define null and missing as equivalent in any given protocol, but assuming it is not.

                  • AggressivelyPassive@feddit.de
                    link
                    fedilink
                    arrow-up
                    1
                    ·
                    12 hours ago

                    Again, did you actually read the comments?

                    Is SQL an API contract using JSON? I hardly think so.

                    Java does not distinguish between null and non-existence within an API contract. Neither does Python. JS is the weird one here for having two different identifiers.

                    Why are you so hellbent on proving something universal that doesn’t apply for the case specified above? Seriously, you’re the “well, ackshually” meme in person. You are unable or unwilling to distinguish between abstract and concrete. And that makes you pretty bad engineers.

        • MostlyBlindGamer@rblind.com
          link
          fedilink
          English
          arrow-up
          7
          ·
          2 days 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.