generating json without nulls

From: Tim Dudgeon <tdudgeon(dot)ml(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: generating json without nulls
Date: 2015-05-07 10:56:42
Message-ID: 554B44EA.4070803@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi All!
I'm using the postgres json functions to generate json for values in a
table.
Something like this:

SELECT row_to_json(a_table) FROM a_table

But my data has lots of null values and that results in json attributes
like this:

"colname":null

I want to exclude those values from the json and only include non-null
values.
Any idea how to best go about this?

Tim

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Andreas Joseph Krogh 2015-05-07 15:16:19 Re: generating json without nulls
Previous Message Adrian Klaver 2015-05-06 14:40:48 Re: [SQL] documenting tables version control