title: Add json array element with jq (cmdline)
body: <p>I'm trying to generate a json file within bash. I installed jq, hoping that it would help me generate and append json.</p>
  
  <p>For example, I want to generate a json in this format:</p>
  
  <pre><code>{
    "Project": [
      {
        "projectName": {
          "branch": [
            {
              "branchName": [
                "path"
              ]
            }
          ],
          "tag": [
            {
              "tagName": [
                "path"
              ]
            }
          ]
        }
      }
    ]
  }
  </code></pre>
  
  <p>While a can to something like that, with the following filter </p>
  
  <pre><code> .Project=.Project+.Project+
    [{"projectName" : {"branch" : (.branch+[{"branchName":(.tagName+["path"])}]),
               "tag": (.tag+[{"tagName":(.tagName+["path"])}]) }}]
  </code></pre>
  
  <p>when I want to create another entry in the same project and name, it creates a whole new entry, has if it was a new project,
  resulting in this:</p>
  
  <pre><code>    {
        "Project": [
          {
            "projectName": {
              "branch": [
                {
                  "branchName": [
                    "path"
                  ]
                }
              ],
              "tag": [
                {
                  "tagName": [
                    "path"
                  ]
                }
              ]
            }
          },
          {
            "projectName": {
              "branch": [
                {
                  "branchName": [
                    "path"
                  ]
                }
              ],
              "tag": [
                {
                  "tagName": [
                    "path"
                  ]
                }
              ]
            }
          },
          {
            "projectName": {
              "branch": [
                {
                  "branchName": [
                    "path2"
                  ]
                }
              ],
              "tag": [
                {
                  "tagName": [
                    "path2"
                  ]
                }
              ]
            }
          }
        ]
      }
  </code></pre>
  
  <p>But I would like to have</p>
  
  <pre><code>{
    "Project": [
      {
        "projectName": {
          "branch": [
            {
              "branchName": [
                "path",
                "path2"
              ]
            }
          ],
          "tag": [
            {
              "tagName": [
                "path",
                "path2"
              ]
            }
          ]
        }
      }
    ]
  }
  </code></pre>
  
  <p>Is there a way with jq/bash?</p>