title: How to convert a JSON with arrays in tsv with jq keeping the array structure?
body: <p>I need to get the content of a mysql table that has some fields that store data as a JSON array, and ingest it in another database table. I need to use a REST API for that, and it returns the records in JSON. For performance reason, I need that output to be tab tab return. Therefore I use jq's @tsv.</p>
  
  <p>This works greats till it encounters a field that has a JSON array inside, jq then complains "array is not valid in a csv row". </p>
  
  <p>Here's a JSON sample</p>
  
  <pre><code>{
  "records": [
   {
          "id": 1,
          "metadata": {
              "description": null,
              "width": 0,
              "height": 0,
              "secondaryColor": "#fff",
              "callToAction": [
                  {
                      "link": "/truc.html",
                      "value": "nice",
                      "colors": {
                          "primary": "transparent;",
                          "secondary": "transparent;"
                      }
                  }
              ]
          },
          "parent": null
      }
          ]
  }
  </code></pre>
  
  <p>I'd like the following result</p>
  
  <pre><code>1  null  0  0  #fff  [ { "link": "/truc.html", "value": "nice", "colors": { "primary": "transparent;", "secondary": "transparent;" } } ]  null
  </code></pre>
  
  <p>so basically I want the array to be intact but just returned in a single row</p>
  
  <p>So I wrote this</p>
  
  <pre><code>jq -c --raw-output '.records[]|[.id,.metadata.description,.metadata.width,.metadata.height,.metadata.secondaryColor,.metadata.callToAction,.parent]|@tsv
  </code></pre>
  
  <p>But I have the "array  is not valid in a csv row" error</p>
  
  <p>Is that possible ?</p>
  
  <p>Thanks</p>