title: Check if string is a valid JSON with jq
body: <p>I need to catch an error when lifting a service. The response can be <code>null</code>, a string error message like</p>
  
  <p><code>error services-migration/foobar: Not found: services-migration/foobar</code> </p>
  
  <p>or a valid JSON when everything is fine. I was wondering if there is a way with <code>jq</code> to simply check if the provided string is a valid JSON. I could ofc check the string for some keywords like <code>error</code> f.e., but I'm looking for a more robust option, where eg. I get a <code>true/false</code> or <code>1/0</code> from jq.
  I was looking through the docs of <code>jq</code> and also some questions here on SO but everything was about finding and picking out key-values from a JSON, but nothing about simply validating a string.</p>
  
  <p>UPDATE:</p>
  
  <p>I've got this:</p>
  
  <pre><code> result=$(some command)
  </code></pre>
  
  <p>from which the result is the string <code>error services-migration/foobar: Not found: services-migration/foobar</code></p>
  
  <p>And then the if statement:</p>
  
  <pre><code> if jq -e . &gt;/dev/null 2&gt;&amp;1 &lt;&lt;&lt;"$result"; then
      echo "it catches it"
   else
      echo "it doesn't catch it"
   fi
  </code></pre>
  
  <p>And it always ends up in the <code>else</code> clause.</p>