title: How can I verify in Postgresql that JSON is valid?
body: <p>I've got a big database with analytics data written in JSON.</p>
  
  <p>I want to filter out rows with incorrect data:</p>
  
  <ul>
  <li>invalid json (some rows has something like that: <code>'{"hello": "world'</code></li>
  <li>some attributes is not array so it would take <code>'{"products": [1,2,3]}'</code> and will leave out the <code>'{"products": 1}'</code></li>
  </ul>
  
  <p>I want to do something like that:</p>
  
  <pre><code>select * 
  from analytics 
  where (is_correct_json(json::json)) 
  and (is_array(json::json-&gt;&gt;'products'))
  </code></pre>
  
  <p>How can I achieve that?</p>