title: Querying inside Postgres JSON arrays
body: <p>How would you go about searching for an element inside an array stored in a <code>json</code> column?  <em>(Update: Also see the 9.4 updated answer for <code>jsonb</code> columns.)</em></p>
  
  <p>If I have a JSON document like this, stored in a <code>json</code> column named <code>blob</code>:</p>
  
  <pre><code>{"name": "Wolf",
   "ids": [185603363281305602,185603363289694211]}
  </code></pre>
  
  <p>what I'd like to be able to do is something like:</p>
  
  <pre><code>SELECT * from "mytable" WHERE 185603363289694211 = ANY("blob"-&gt;'ids');
  </code></pre>
  
  <p>and get all matching rows out.  But this doesn't work because <code>"blob"-&gt;'ids'</code> returns JSON values, not Postgres arrays.</p>
  
  <p>I'd also like to build an index on the individual IDs, if that's possible.</p>