Table "public.users"
Column | Type | Modifiers
--------------+---------+------------
user_id | integer | not null
user_name | text |
user_profile | json |
Better is that there are multiple JSON conversion functions, including row_to_json() and array_to_json(), which allow you to get the results of a query in JSON format.
select row_to_json(names)
from ( select schemaname, relname from pg_stat_user_tables )
as names;
row_to_json
-------------------------------------------
{"schemaname":"public","relname":"users"}