title: postgres9.4 loop through jsonb: how select vals of key:val pairs
body: <p>This plpgsql script selects the keys from a set of jsonb object key:value pairs, but how to select the value for each pair?</p>
  
  <pre><code>DO
  $BODY$
  DECLARE
      js jsonb := '{"a": "1", "b": "2", "c": "3"}';
      i text;
  BEGIN
    FOR i IN SELECT * FROM jsonb_each_text(js)
    LOOP
      RAISE NOTICE 'key %', i;
      --RAISE NOTICE 'value %', i.value; &lt;--fai
    END LOOP;
  END;
  $BODY$;
  </code></pre>
  
  <p>Should be possible as man page <a href="http://www.postgresql.org/docs/9.4/static/functions-json.html" rel="nofollow noreferrer">http://www.postgresql.org/docs/9.4/static/functions-json.html</a> indicates return value is setof key text, value text. This post <a href="https://stackoverflow.com/questions/9783422/postgres-array-for-loop">Postgres - array for loop</a> answers the question for array.
  Also tried jsonb_each() and jsonb_array_elements() changing iterator to jsonb, with error "Cannot extract element from an object"</p>