• Avicenna@programming.dev
    link
    fedilink
    arrow-up
    59
    ·
    16 days ago

    alternative scenerio:

    Guy: “it turns javascript objects into texts in json format”

    Soldier: “He uses javascript, shoot the poor bastard”

    • Blue Label@lemmy.world
      link
      fedilink
      English
      arrow-up
      21
      ·
      edit-2
      16 days ago

      Alternative scenario:

      Soldier B: Soldier A asked a JavaScript question instead of a software engineering question. He’s not a real soldier, shoot him

        • Rose@slrpnk.net
          link
          fedilink
          arrow-up
          0
          ·
          16 days ago

          Name 3 UML diagrams

          Class diagram, use case diagram and… What was the useless, barely readable evolution of flowcharts called again? Activity diagram?

          and 3 architectures!

          MOS 6502, amd64, and… I’ve never figured out the ARM naming scheme. AAAAAAarch64 or something?

  • lime!@feddit.nu
    link
    fedilink
    arrow-up
    19
    ·
    16 days ago

    i’ve designed my own communication protocols that run directly on udp. i couldn’t tell you either.

    • MalReynolds@slrpnk.net
      link
      fedilink
      English
      arrow-up
      6
      ·
      16 days ago

      Ima guess it’s javascript-ese to turn a json object into a string, perhaps for serialization. But no clue, coding for decades but always hated js, I guess my way through with a linter and IDE when I absolutely, positively, cannot find an alternative, which seldom happens.

        • anomnom@sh.itjust.works
          link
          fedilink
          English
          arrow-up
          1
          ·
          16 days ago

          Before yaml, I used json with Ruby it was way nicer to read than xml config files ( but way before that I started using it with PHP and Actionscript)

          • jaybone@lemmy.zip
            link
            fedilink
            English
            arrow-up
            3
            ·
            16 days ago

            Yeah you don’t have to be using JavaScript to use json. Yes I know it’s part of the name, but it’s just an object notation which is the other part of the name, and this has become widely accepted for use in nearly all popular languages and frameworks.

            • lad@programming.dev
              link
              fedilink
              arrow-up
              1
              ·
              16 days ago

              Are there any other languages that would also have Json.Stringify? I only read JS sometimes and never write those, so I may be wrong about that.

              JSON itself is fine, yeah

              • anomnom@sh.itjust.works
                link
                fedilink
                English
                arrow-up
                1
                ·
                16 days ago

                Not sure but with Ruby it was JSON.generate(ruby_object).

                And it returned - JSON string of your argument.

    • ramble81@lemmy.zip
      link
      fedilink
      arrow-up
      4
      ·
      16 days ago

      I mean, that’s fine, right up till you have to communicate with something else. Given that 99% of APIs out there use JSON.

    • lobut@lemmy.ca
      link
      fedilink
      arrow-up
      0
      ·
      16 days ago

      I refuse to believe you couldn’t infer what this is, you’re way too smart and you could definitely just guess.

      • lime!@feddit.nu
        link
        fedilink
        arrow-up
        1
        ·
        16 days ago

        turning a data structure into a string is usually called like “marshal” or “render” or “dump” or something, “stringify” doesn’t really imply anything except something about the json being turned into a string. for all i know it could be replacing all the values with toString’ed versions.

        • Buddahriffic@lemmy.world
          link
          fedilink
          arrow-up
          1
          ·
          16 days ago

          Another guess just based on the terms is it could be a method that throws your json object into a black hole and returns the version of the object that is stretched out to infinity.

          Though that’s just an optical illusion, in reality the object would be ripped apart by the gravity or extreme radiation, depending on whether it was a small or large black hole.

          Your guesses are more useful, but I can’t fathom what goes on in the mind of JavaScript devs.

  • _stranger_@lemmy.world
    link
    fedilink
    arrow-up
    9
    ·
    16 days ago

    Ugh, terrible memory unlocked.

    I asked someone a similar question in an interview once. They weren’t doing well and I wanted to end on a positive at least. I asked them to make a dict in python and for extra credit, turn it into a string using whatever library or method they want.

    This was not for a junior position.

    5 minutes of for loop insanity later they disconnected crying. I always felt bad for that guy.

        • mel ♀@jlai.lu
          link
          fedilink
          arrow-up
          0
          ·
          15 days ago

          I think json.dumps would not work if there is a datetime in the dict, right?

          • _stranger_@lemmy.world
            link
            fedilink
            arrow-up
            1
            ·
            15 days ago

            Yeah there’s other edge cases too, like Decimal, but as long as you have those things imported when you send it through dumps it should work.

            • mel ♀@jlai.lu
              link
              fedilink
              arrow-up
              1
              ·
              15 days ago

              Just tried it in an ipython shell

              import datetime
              import json
              
              json.dumps({"a": datetime.datetime(1970,1,1)})
              

              And I got the TypeError: datetime not JSON serializable though.

              • _stranger_@lemmy.world
                link
                fedilink
                arrow-up
                1
                ·
                15 days ago

                If you don’t care you can pass in default=str (I think) but if you do care you can define a function for what the string representation should look like and pass that in, but that’s a happy path case to be honest. I usually only run into this problem when something is logging unk own data, so I pass in the default=str just to get it functional.

                Duck typing usually works but, datetime man, datetime is the warp from Warhammer 40K, it will drive you mad.

  • porous_grey_matter@lemmy.ml
    link
    fedilink
    arrow-up
    7
    ·
    16 days ago

    Not sure every software engineer needs to know this. If they’d said web developer I suppose this would really be expected knowledge, but then you’d probably want to shoot them anyway.

    • SparroHawc@piefed.world
      link
      fedilink
      English
      arrow-up
      2
      ·
      16 days ago

      Web developer, or business developer. A lot of inter-system communications these days is in JSON, whether there is any JavaScript involved or not.

    • Waterpumpee@lemmus.org
      link
      fedilink
      English
      arrow-up
      1
      ·
      16 days ago

      honestly, this is used for debugging. Why not just pass the object as value to the console.log()

      • jaybone@lemmy.zip
        link
        fedilink
        English
        arrow-up
        0
        ·
        16 days ago

        Stringify is used to serialize an object. This is useful if you are going to store the object or transfer the object contents to some other system or component, possibly over a network using a network protocol.

        For debugging, you should use a function like console.log, which depending on the client might even offer an interactive UI to explore the object with structurally aware context. Not just print a giant string, which you get from stringify.

    • Pup Biru@aussie.zone
      link
      fedilink
      English
      arrow-up
      2
      ·
      16 days ago

      i agree but hate to add the caveat that it (well, typescript) these days is by far the language that i’m most productive in, with the fewest bugs

      it took me a long time to admit that to myself

      it’s still a human rights violation