title: How-to loop over JSON Arrays in postgresql 9.3
body: <p>I'm writing function for a new postgreSQL db and i'm trying to loop over a nested structure.  </p>
  
  <p>Is that even possible with the new JSON functions?
  What i'm trying to do is here below:</p>
  
  <pre><code>DO
  $BODY$
  DECLARE
      omgjson json := '[{ "type": false }, { "type": "photo" }, {"type": "comment" }]';
      i record;
  BEGIN
    FOR i IN SELECT * FROM json_array_elements(omgjson)
    LOOP
      RAISE NOTICE 'output from space %', i;
    END LOOP;
  END;
  $BODY$ language plpgsql
  </code></pre>
  
  <p>This returns a set of records (text!), that is not JSON! so i cannot query it like <code>i-&gt;&gt;'type'</code>, but that's exactly what i want to accomplish...</p>