Received: from makus.postgresql.org ([98.129.198.125]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TSNKy-0003fu-C4 for pgsql-bugs@postgresql.org; Sun, 28 Oct 2012 07:31:12 +0000 Received: from mail-pb0-f46.google.com ([209.85.160.46]) by makus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TSNKq-0008Mx-Oi for pgsql-bugs@postgresql.org; Sun, 28 Oct 2012 07:31:09 +0000 Received: by mail-pb0-f46.google.com with SMTP id rr4so3612792pbb.19 for ; Sun, 28 Oct 2012 00:31:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding:x-gm-message-state; bh=She3JgWFfEu7zu1dWrdvSX/RrZ1uUaV8lAm2CUpNVTQ=; b=UMVJKU5VTMEAZEusgGS7Zll4iWptGZu1sLB7RAsCzKDLIgq6AZWZBj75sm9+DC/7pI yw2nHTq1zntRakLx+Gx64XYCrm56YL/40VIERuUVtUP17+/1rEQgfV8dNSGybPIOKpYv kkX+4TOwoJZhSgBaHI2NyH5tkQDlGQdK47fl3eoCHRbe0+EFo7GtyM19vwdzpQ3ltRKO OfVwo8iPMs3q2RLUrV7QR71yIZnW2eK7tmIx7Js3+2gveHWKuU0F4n+MgRuh0CYxQzyn N7WovfwPYKzGIKBnd591i6rWm+bPmj/E2TrL6E+ejyuJ6PVgxdrhr/U2afPKIYc7Za4L bx+w== Received: by 10.68.223.135 with SMTP id qu7mr83531078pbc.143.1351409459983; Sun, 28 Oct 2012 00:30:59 -0700 (PDT) Received: from ayaki.localdomain (124-148-78-49.dyn.iinet.net.au. [124.148.78.49]) by mx.google.com with ESMTPS id gu5sm595584pbc.10.2012.10.28.00.30.57 (version=SSLv3 cipher=OTHER); Sun, 28 Oct 2012 00:30:58 -0700 (PDT) Message-ID: <508CDF2E.7060305@ringerc.id.au> Date: Sun, 28 Oct 2012 15:30:54 +0800 From: Craig Ringer User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121016 Thunderbird/16.0.1 MIME-Version: 1.0 To: Greg Hazel CC: pgsql-bugs@postgresql.org Subject: Re: BUG #7620: array_to_json doesn't support heterogeneous arrays References: <50879711.6020209@ringerc.id.au> In-Reply-To: X-Enigmail-Version: 1.4.5 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Gm-Message-State: ALoCoQkxZse3PP7FUdMJ3BkMUgRNUfyUk6/6nRaM7YXjL6HGZWkTpJVjCPU0NGyOyNa4asM217MM X-Pg-Spam-Score: -1.9 (-) X-Archive-Number: 201210/228 X-Sequence-Number: 34528 On 10/24/2012 11:46 PM, Greg Hazel wrote: > Another option that just occurred to me is a new function (say, to_json) that converts the parameter to its json representation, with type json. > > Then this would be possible: > > select array_to_json(ARRAY[to_json('foo'), to_json(100), to_json(true)]); That's been repeatedly discussed (and requested, and had patches posted) on -hackers. Right now the standing opinion appears to be that "json" represents a whole json document, and json documents must be arrays or JavaScript objects, not scalars, so it is not valid to provide a scalar "to_json". I posted patches to support this functionality - as did several others as it turns out - and they've all been rejected. -- Craig Ringer