title: How to extract key and value from json column in Postgres?
body: <p>I want to add key-value pairs extracted from json column to table with Postgresql.</p>
  
  <p>I have an items_table with uid and data column in json with multiple pairs. Initial table that looks like:</p>
  
  <pre><code>uid | data
  
  1   | {"item1":"string1", "item2":"string2"}
  2   | {"item2":"string3", "item5":"string1", "item7":"string5"}
  3   | {"item1":"string3", "item4":"string1", "item6":"string8", "item5":"string5"}
  4   | {"item1":"string4"}
  </code></pre>
  
  <p>...</p>
  
  <p>Thus, some items/strings can repeat and fields length can vary as well.</p>
  
  <p>I tried apply jsonb_object_keys, mentioned in documentation, however I occurred an error.</p>
  
  <pre><code>     select jsonb_object_keys(data) 
       from items_table;
  </code></pre>
  
  <p><strong>ERROR</strong>: <em>function jsonb_object_keys(character varying) does not exist Hint: No function matches the given name and argument types. You may need to add explicit type casts</em>.</p>
  
  <p>I would like obtain a table result in following way to get split by items and strings, expanding uid column:</p>
  
  <pre><code>uid | items      | strings
  
  1   | item1      | string1
  1   | item2      | string2
  2   | item2      | string3
  2   | item5      | string1
  2   | item7      | string5
  3   | item1      | string3
  3   | item4      | string1
  3   | item6      | string8
  3   | item5      | string5
  4   | item1      | string4
  </code></pre>
  
  <p>How is it possible to achieve the above output?</p>