1. 19
  1.  

  2. 5

    There’s a jc web demo that allows pasting in any text and selecting a filter to see how the data is parsed.

    There’s also a jc Ansible filter as well that allows simply parsing structured data from remote command output.

    Pretty neat!

    - name: Get Timezone
      hosts: ubuntu
      tasks:
      - shell: date
        register: result
      - set_fact:
          myvar: "{{ result.stdout | community.general.jc('date') }}"
      - debug:
          msg: "The timezone is: {{ myvar.timezone }}"
    
    1. 4

      it’d be neat if this was a statically linked binary

      1. 1

        Linux, macOS, and Windows binaries are available under Releases in the Github page.

      2. 3

        Looks great! I tried Nu Shell once and took some time to figure out how to parse the output of traditional Unix commands into structured data, which I was never quite comportable with and would have to learn all over again to try another data-driven shell; a do-one-thing tool like this lowers the barrier of entry for data-driven-shell-hopping.

        1. 2

          Here is a Wiki page showing how jc can be used in several different shells: https://github.com/kellyjonbrazil/jc/wiki/Using-jc-With-Different-Shells

        2. 2

          Love this! And I think more of these tools popping up and –format flags for many tools is indicative of a demand for easier interoperability. It seems like the majority of “command” invocations are coming from applications, not humans. So a human-friendly output format is often spending more engineering time when piping things together.

          1. 2

            Then, you can pipe to https://github.com/tomnomnom/gron to use the output.