title: JSON JQ if without else
body: <p>I use the following JQ command to filter out the JSON. My requirement is to filter out the JSON message if the expected node is present. Or else, do nothing. Hence, I use if, elif, ....</p>
  
  <pre><code>sed -n "s/.*Service - //p" $1/response.log* |
    jq "if (.requests | length) != 0 then .requests |= map(select(.id == \"123\"))
        elif (.result | length ) != 0  then .result |= map(select(.id== \"123\")) 
        else " "  end" &gt; ~/result.log
  </code></pre>
  
  <p>Looks like else is mandatory here. I dont want to do anything inside the else block. Is there anyway, I can ignore else or just print some whitespce inside else.</p>
  
  <p>In the above case, it prints double quotes " " in the result file.</p>