I hope I am not missing something very obvious here,
I want to get JSON output from a postgres function (I imagine many other had already needed this) and I\'d be happy
On the server install:
sudo apt-get install postgresql-plpython-9.4
Then on your Postgres server:
CREATE EXTENSION IF NOT EXISTS plpythonu;
CREATE LANGUAGE plpythonu;
CREATE OR REPLACE FUNCTION prettyprint_json(data text)
RETURNS json
AS $$
import json
return json.dumps(json.loads(data), indent=4)
$$ LANGUAGE plpythonu;