Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YqJU3-0000BA-6k for pgsql-sql@arkaria.postgresql.org; Thu, 07 May 2015 10:56:51 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YqJU1-0007uT-VZ for pgsql-sql@arkaria.postgresql.org; Thu, 07 May 2015 10:56:50 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YqJU0-0007uM-Rd for pgsql-sql@postgresql.org; Thu, 07 May 2015 10:56:49 +0000 Received: from mail-wi0-x231.google.com ([2a00:1450:400c:c05::231]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.84) (envelope-from ) id 1YqJTy-0001DZ-B2 for pgsql-sql@postgresql.org; Thu, 07 May 2015 10:56:48 +0000 Received: by wiun10 with SMTP id n10so55001011wiu.1 for ; Thu, 07 May 2015 03:56:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=m+WDcIIvTumn+q89o07+l93Qe4uH8wpd98Y4PvHynko=; b=NCN+BUv+CkAVlSb0iF3yW6MHSyc/D5kt7EVOf2gevL2NHSm/PcC69D9ircsa8GN/Eh p+uskNDyWmYOJNjCykSQcmuC61RnZJdRWge2lbT6z+w2DvlZMoeU7jaIuTR6xOCsRd8s 4sDnC59GaIHXk61SsrK7QEZSYAF9n5fMoMPATdpODqsbhlZKv4gmYIB971LAY7XXXPxx CxVHsclLDEWaf9sLZUjGPVkJZ/oyTscuvBUyMqgEdbH2vDAaXDPPVZSjeuuxWeUkpXXc L8lwtB5sBGzA+cWjs244CD0sLS2lB7AXw1+4ilPSnPUUCRUgtcraoDqoEuOfRrt36mzV jSYg== X-Received: by 10.194.104.71 with SMTP id gc7mr6081818wjb.114.1430996205287; Thu, 07 May 2015 03:56:45 -0700 (PDT) Received: from timbomac.home (host86-147-75-147.range86-147.btcentralplus.com. [86.147.75.147]) by mx.google.com with ESMTPSA id i6sm2794796wjf.29.2015.05.07.03.56.43 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 03:56:44 -0700 (PDT) Message-ID: <554B44EA.4070803@gmail.com> Date: Thu, 07 May 2015 11:56:42 +0100 From: Tim Dudgeon User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: generating json without nulls Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -2.7 (--) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org 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 -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql