title: How do I check the type of a field contained in a JSONB?
body: <p>I'm hoping this is a fairly simple question with a simple answer.</p>
  <p>In PostgreSQL I have a table with a Answer column that is a <code>jsonb</code>.
  As of right now, the data that can be stored in the column can be empty or quite varied. Some examples include:</p>
  <ul>
  <li><code>{&quot;Answer&quot;:&quot;My name is Fred&quot;}</code></li>
  <li><code>{&quot;Answer&quot;:[{&quot;text&quot;: &quot;choice 1&quot;, &quot;isActive&quot;: true}, {&quot;text&quot;: &quot;choice 2&quot;, &quot;isActive&quot;: false}]}</code></li>
  </ul>
  <p>Yes, we store a field called <code>Answer</code> in our column called <code>Answer</code>. Not sure why, but that is how it is.</p>
  <p>I want to be able to test if the JSON attribute <code>Answer</code> contains a string or an array. But I don't know how, and I must be wording my searches incorrectly. I'm not finding anything concrete. I already know how to check if <code>Answer</code> exists. Just can't tell what it contains.</p>
  <p>Does anyone know how I would do this? Or if there isn't a way, what I need to do instead to query this data?</p>