title: How can I select records that match a value in a json field array?
body: <p>I'm trying to return records matching an array element that equals a specific value from a json field.</p>
  
  <p>I found <a href="https://stackoverflow.com/questions/57564309/how-to-select-all-records-containing-certain-values-from-a-postgres-json-field-c">how to select all records containing certain values from a postgres json field containig an array</a> that is close to my question. However, I think the key difference is I use json and not jsonb. For reasons, I need to use json at the moment. When I tried the steps from that other post, I get the same error as below.</p>
  
  <p>I have this example <code>data</code></p>
  
  <pre><code>{"name": "Bob", "scores": [64, 66]}
  {"name": "Sally", "scores": [66, 65]}
  {"name": "Kurt", "scores": [69, 71, 72, 67, 68]}
  {"name": "Libby", "scores": [72, 73, 74, 75]}
  {"name": "Frank", "scores": [80, 81, 82, 83]}
  </code></pre>
  
  <p>I'm trying to run this query:</p>
  
  <pre><code>SELECT data
  FROM tests.results
  where (data-&gt;&gt;'scores') @&gt; '[72]';
  </code></pre>
  
  <p>I expect two rows from the results:</p>
  
  <pre><code>{"name": "Kurt", "scores": [69, 71, 72, 67, 68]}
  {"name": "Libby", "scores": [72, 73, 74, 75]}
  </code></pre>
  
  <p>but I get:</p>
  
  <pre><code>SQL Error [42883]: ERROR: operator does not exist: text @&gt; integer
    Hint: No operator matches the given name and argument type(s). 
    You might need to add explicit type casts.
  </code></pre>
  
  <p>I currently using Postgres 10, but am likely upgrading to 12. Any help is appreciated.</p>