Re: Bypassing NULL elements in row_to_json function

From: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
To: Michael Nolan <htfoot(at)gmail(dot)com>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Bypassing NULL elements in row_to_json function
Date: 2016-04-08 16:47:12
Message-ID: 5707E090.5090309@aklaver.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 04/08/2016 08:31 AM, Michael Nolan wrote:
> I'm looking at the possibility of using JSON as a data exchange format
> with some apps running on both PCs and Macs. .
>
> The table I would be exporting has a lot of NULL values in it. Is
> there any way to skip the NULL values in the row_to_json function and
> include only the fields that are non-null?

I guess it depends on your data.

Are the NULLs all in one field or scattered across fields?

Imagining this scenario:

fld_1 fld_2 fld_3
'val1_1' NULL 'val1_3
NULL 'val2_2' 'val2_3'
'val3_3' 'val3_2' NULL

How do you deal with the holes(NULL) on the receiving end?

> --
> Mike Nolan
> nolan(at)tssi(dot)com
>
>

--
Adrian Klaver
adrian(dot)klaver(at)aklaver(dot)com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2016-04-08 17:07:51 Re: Transitioning to a SQL db
Previous Message David G. Johnston 2016-04-08 16:44:29 Re: Bypassing NULL elements in row_to_json function