• Tangent5280@lemmy.world
      link
      fedilink
      arrow-up
      3
      ·
      4 hours ago

      The important part is to learn the limits of any tool. Nowadays I no longer use jq for any long or complicated tasking. Filter and view data? jq is fine. Anything more and I just cook up a python script.

        • Tangent5280@lemmy.world
          link
          fedilink
          arrow-up
          2
          ·
          3 hours ago

          How do you get complex data structures to work? I was alienated from scripting on zsh because I wanted something like a dict and realised I would have to write my own implementation. Is there a work around for that?

          • tal@lemmy.today
            link
            fedilink
            English
            arrow-up
            3
            ·
            edit-2
            1 hour ago

            I mean, there’s a point in data structure complexity where it’s useful to use Python.

            But as to dicts, sure. You’re looking for zsh’s “associative array”. Bash has it too.

            zsh

            $ typeset -A mydict
            $ mydict[foo]=bar 
            $ echo $mydict[foo]
            bar
            $
            

            bash

            $ typeset -A mydict
            $ mydict[foo]=bar
            $ echo ${mydict[foo]}
            bar
            $
            
            • Tangent5280@lemmy.world
              link
              fedilink
              arrow-up
              3
              ·
              1 hour ago

              This will do nicely - I had several workflows where I’d hit an API and get a massive super nested JSON as output; I’d use jq to get the specific data from the whole thing and do a bunch of stuff on this filtered data. I pretty much resigned to using python because I’d have successively complicated requirements and looking up how to do each new thing was slowing me down massively.