title: postgresql: Filter in JSON array
body: <p>Let's say we have a table <code>items</code> which has columns <code>name</code> and <code>attributes</code>:</p>
  
  <pre><code>CREATE TABLE students (
    name VARCHAR(100),
    attributes JSON
  )
  </code></pre>
  
  <p>where attributes is an array of (always equally-structured) JSON documents such as</p>
  
  <pre><code>[{"name":"Attribute 1","value":"Value 1"},{"name":"Attribute 2","value":"Value 2"}]
  </code></pre>
  
  <p>I now want to find all students where any attribute value matches something (such as <code>Foo%</code>). <a href="https://www.db-fiddle.com/f/w9DRUoELG43Z4FdCXtsieo/1" rel="noreferrer">Here's a playground example</a>.</p>
  
  <p>I realize that this isn't exactly the most straight-forward design, but for now it's what I have to work with, though performance of such a search being categorically terribly inefficient would of course be a valid concern.</p>