with t as(SELECT table_name, column_name, data_type, ROW_NUMBER() OVER (PARTITION BY table_name ORDER BY column_name) as num
FROM information_schema.columns
WHERE table_schema = 'public')
select concat('{', string_agg(concat('"', num, '"', ':', json_build_object(column_name, data_type))::text, ','), '}')::json from t group by table_name;