Postgres jsonb complex query
I think the first level of arrays is not useful, especially if you are going to retrieve permissions by name. 

I would store it like this:

CREATE TABLE forms (id serial, form jsonb);
INSERT INTO forms (id, form) VALUES 
(1, '{"permissions": 
         {"perm-name-1": {"who": ["group1","group2"]}, 
          "perm-name-2": {"who": ["group1","group3"]}}
     }'), 
(2, '{"permissions": 
         {"perm-name-1": {"who": ["group5","group6"]}, 
          "perm-name-2": {"who": ["group7","group8"]}}
     }');


Then both your queries are quite easy to write: 

For the first one you can use the "any" operator ?|:

select *
from forms
where form -&gt; 'permissions' -&gt; 'perm-name-1' -&gt; 'who' ?| array['group1', 'group5']


For the second one, the ? operator is enough:

select *
from forms
where form -&gt; 'permissions' -&gt; 'perm-name-1' -&gt; 'who' ? 'group1'




You didn't ask for it, but you can also query for rows where a specific permissions contains all specified groups. That can be done using the ?&amp; operator. The following would return the row with ID=1

select *
from forms
where form -&gt; 'permissions' -&gt; 'perm-name-1' -&gt; 'who' ?&amp; array['group1', 'group2'];


The following would return nothing:

select *
from forms
where form -&gt; 'permissions' -&gt; 'perm-name-1' -&gt; 'who' ?&amp; array['group2', 'group3'];