title: How to convert complex JSON to CSV using JQ 1.4
body: <p>I am using JQ 1.4 on Windows 64 bit machine.</p>
  
  <p>Below are the contents of input file <code>IP.txt</code></p>
  
  <pre><code>{
    "results": [
      {
        "name": "Google",
        "employees": [
          {
            "name": "Michael",
            "division": "Engineering"
          },
          {
            "name": "Laura",
            "division": "HR"
          },
          {
            "name": "Elise",
            "division": "Marketing"
          }
        ]
      },
      {
        "name": "Microsoft",
        "employees": [
          {
            "name": "Brett",
            "division": "Engineering"
          },
          {
            "name": "David",
            "division": "HR"
          }
        ]
      }
    ]
  }
  
  {
    "results": [
      {
        "name": "Amazon",
        "employees": [
          {
            "name": "Watson",
            "division": "Marketing"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>File contains two <code>"results"</code>. 1st result containts information for 2 companies: <code>Google</code> and <code>Microsoft</code>. 2nd result contains information for <code>Amazon</code>.
  I want to convert this JSON into csv file with company name and employee name.</p>
  
  <pre><code>"Google","Michael"
  "Google","Laura"
  "Google","Elise"
  "Microsoft","Brett"
  "Microsoft","David"
  "Amazon","Watson"
  </code></pre>
  
  <p>I am able to write below script:</p>
  
  <pre><code>jq -r "[.results[0].name,.results[0].employees[0].name]|@csv" IP.txt
  
  "Google","Michael"
  
  "Amazon","Watson"
  </code></pre>
  
  <p>Can someone guide me to write the script without hardcoding the index values?</p>
  
  <p>Script should be able generate output for any number <code>results</code> and each cotaining information of any number of companies.</p>
  
  <p>I tried using below script which didn't generate expected output:</p>
  
  <pre><code>jq -r "[.results[].name,.results[].employees[].name]|@csv" IP.txt
  "Google","Microsoft","Michael","Laura","Elise","Brett","David"
  "Amazon","Watson"
  </code></pre>