title: Loop through JSON object to get value for given property name
body: <p>I have some JSON-objects and I need to fetch property values for them.<br>
  My situation is based on this query:</p>
  
  <pre><code>DO $$
  DECLARE 
  v_whatever character varying := 'a';
  v_res character varying;
  BEGIN
  SELECT params-&gt;&gt;v_whatever FROM user_info1 WHERE uid = 9 INTO v_res;
  RAISE NOTICE 'v_res: %', v_res ;
  END; $$
  </code></pre>
  
  <p>In table, value for column params(type json) is: <code>{"a":"b","b":"c","c":"d"}</code> ,
  Query returns <code>v_res: b</code> </p>
  
  <p>Because I don't have specific property names, code looks like this:</p>
  
  <pre><code>DECLARE
  v_temp char varying;
  v_obj char varying[];
  comp char varying[];
  BEGIN
  SELECT json_object_keys(params) FROM  user_info1 WHERE uid = p_uid into v_temp;
  SELECT params-&gt;&gt;v_temp FROM user_info1 WHERE uid = 9 INTO v_obj;
  </code></pre>