function return multiple json rows
You need to also return multiple rows, not just a single value. You also don't need PL/pgSQL for this. A simple SQL function will do:

create or replace function myfunc()
  returns table (document json) 
as
$body$
  select row_to_json(myview) 
  from myview;
$body$
language sql;


returns table is the same as returns setof but you can define the column names.

You also need to put the function call into the from clause:

select * 
from myfunc();




You don't really need function for that in the first  place. You could do that in the view directly:

create view myview 
as 
select row_to_json(t) as document
from (
  select retailerid, retailername
  from mytable
)t ;