3 ms·
I was looking for a way to pretty print json in postgres today, the simplest I came up with is a 'json_mode.sql' script: \t on \pset pager always \pset f
by jackhalford 5y ago
I was looking for a way to pretty print json in postgres today, the simplest I came up with is a 'json_mode.sql' script:
\t on
\pset pager always
\pset format unaligned
\setenv PAGER 'jq .'
then all selects of a json column are readable.
- ttfkam 5y agoWhy not: jsonb_pretty(jsonb) → text or jsonb_to_record(jsonb) → record jsonb_to_recordset(jsonb) → setof record https://www.postgresql.org/docs/current/functions-json.html https://www.postgresql.org/docs/current/functions-json.html
- jackhalford 5y agoI came across this while googling but it seems the jsonb_pretty function isn't available in my postgres