title: json - query with conditions
body: <p>I have following json:</p>
  
  <pre><code>{
    "id": "1",
    "name": "profile1",
    "userId": "0",
    "groupId": "3",
    "attributes": [
      {
        "id": "104",
        "name": "Enable",
        "value": "1"
      },
      {
        "id": "105",
        "name": "TargetNode",
        "value": "system1"
      },
      {
        "id": "106",
        "name": "Timeout",
        "value": "30"
      }
    ],
    "xconns": [
      {
        "id": "1",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      },
      {
        "id": "1",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      },
      {
        "id": "1",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      }
    ]
  }
  {
    "id": "2",
    "name": "profile2",
    "userId": "7",
    "groupId": "0",
    "attributes": [
      {
        "id": "104",
        "name": "Enable",
        "value": "1"
      },
      {
        "id": "105",
        "name": "TargetNode",
        "value": "system2"
      },
      {
        "id": "106",
        "name": "Timeout",
        "value": "30"
      }
    ],
    "xconns": [
      {
        "id": "2",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      },
      {
        "id": "2",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      },
      {
        "id": "2",
        "locked": false,
        "attributeList": [
          {
            "id": "101",
            "name": "Lgrp",
            "value": "1"
          },
          {
            "id": "102",
            "name": "IsRem",
            "value": "1"
          },
          {
            "id": "103",
            "name": "Media",
            "value": "1"
          }
        ]
      }
    ]
  }
  </code></pre>
  
  <p>I can filter following:</p>
  
  <pre><code>$ jq -r 'select([.attributes[] | .name == "TargetNode" ] | any ) | [{userId, groupId, id, name}] | .[] | if (.userId == "0") then del(.userId) else . end | if (.groupId == "0") then del(.groupId) else . end | to_entries | map("\(.key | ascii_upcase):\(.value)") | @tsv' file.json
  GROUPID:3       ID:1    NAME:profile1
  USERID:7        ID:2    NAME:profile2
  </code></pre>
  
  <p>I need to add also value of TargetNode:</p>
  
  <pre><code>GROUPID:3       ID:1    NAME:profile1    TARGETNODE:system1
  USERID:7        ID:2    NAME:profile2    TARGETNODE:system2
  </code></pre>
  
  <p>is there a way to include it in 
  [{userId, groupId, id, name, TargetNode}] 
  to get the value of TargetNode and not null?</p>
  
  <p>GROUPID:3       ID:1    NAME:profile1   TARGETNODE:null</p>
  
  <p>USERID:7        ID:2    NAME:profile2   TARGETNODE:null</p>
  
  <p>Update:
  the solution provided by RomanPerekhrest is nearly ok, but there is one issue because the json file in real is much bigger, there are more attrobutes in "main secttion", for example:</p>
  
  <pre><code>{
    "id": "1",
    "name": "profile1",
    "userId": "0",
    "groupId": "3",
    "attrib101": "A",
    "attrib102": "B",
    "attributes": [
  ...
  ...
  </code></pre>
  
  <p>it is cousing that RomanPerekhrest's jq filter returns too much...
  how to rid of them too?</p>
  
  <pre><code>ID:1    NAME:profile1   GROUPID:3   ATTRIB101:A     ATTRIB102:B TARGETNODE:system1
  ID:2    NAME:profile2   USERID:7    ATTRIB101:C     ATTRIB102:D TARGETNODE:system2
  </code></pre>