title: json filtering in bash
body: <p>I would like to ask you if you can help me with filtering data in json. I have the following json:</p>
  <pre><code>{
      &quot;cluster_name&quot;: &quot;k8s-cluster-1&quot;,
      &quot;cluster_env&quot;: &quot;PROD&quot;,
      &quot;cluster_hosts&quot;: [
        {
          &quot;host_type&quot;: &quot;MASTER&quot;,
          &quot;host_hostname&quot;: &quot;aa083&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        },
        {
          &quot;host_type&quot;: &quot;NODE&quot;,
          &quot;host_hostname&quot;: &quot;aa084&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        },
        {
          &quot;host_type&quot;: &quot;NODE&quot;,
          &quot;host_hostname&quot;: &quot;aa085&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        }
      ],
  },
  {
      &quot;cluster_name&quot;: &quot;k8s-cluster-2&quot;,
      &quot;cluster_env&quot;: &quot;PROD&quot;,
      &quot;cluster_hosts&quot;: [
        {
          &quot;host_type&quot;: &quot;MASTER&quot;,
          &quot;host_hostname&quot;: &quot;ab093&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        },
        {
          &quot;host_type&quot;: &quot;NODE&quot;,
          &quot;host_hostname&quot;: &quot;ab094&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        },
        {
          &quot;host_type&quot;: &quot;NODE&quot;,
          &quot;host_hostname&quot;: &quot;ab095&quot;,
          &quot;host_username&quot;: &quot;kubeadm&quot;,
          &quot;host_kubernetes_version&quot;: &quot;&quot;,
        }
      ],
  }
  </code></pre>
  <p>And the output should look like this:</p>
  <pre><code>cluster_name
  host_type
  host_name
  .
  .
  .
  </code></pre>
  <pre><code>k8s-cluster-1
  MASTER
  aa083
  NODE
  aa084
  NODE
  aa085
  k8s-cluster-2
  MASTER
  ab093
  NODE
  ab094
  NODE
  ab095
  </code></pre>
  <p>I tried this command</p>
  <p>cat json |jq -c '.[] | .cluster_name,.cluster_hosts[] | {host_type,host_name}'</p>
  <p>but it shows an error</p>
  <p>jq: error (at :1): Cannot index string with string &quot;host_type&quot;</p>
  <p>I need to do this in bash.</p>
  <p>Could you please help me?</p>
  <p>Thank you in advance.</p>