Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TQpQ0-0002fs-Ag for pgsql-bugs@postgresql.org; Wed, 24 Oct 2012 01:06:00 +0000 Received: from mail-pa0-f46.google.com ([209.85.220.46]) by magus.postgresql.org with esmtp (Exim 4.72) (envelope-from ) id 1TQpPt-00081w-Cc for pgsql-bugs@postgresql.org; Wed, 24 Oct 2012 01:06:00 +0000 Received: by mail-pa0-f46.google.com with SMTP id hz1so3162473pad.19 for ; Tue, 23 Oct 2012 18:05:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=content-type:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; bh=5EAtPJTTfUpt/YaEdsEh+wX+2PWbbDpUXYR4u+IC2l0=; b=jSAI+OApZQiGRdbbrgrPBnbtREGtld8llrmX8ItNS+b1Nmlz7OzJFk+3nxhS+iY1Jl Tmi+3wVQ9NcSVdag32Qt3AjDE9sX9U0nf2xm4ORfMHz3aHEzBd4WQjJ8HWvqmMGSm91G wo2ZKbNqDdA4CUjjCJDmwX0nzTCcrYzUStl9PHTYuGGX/be9WpXhngYZMG/+fYPFZyA2 bprJSjC698PllFnYbkyMxS1mlgcZ5ed7vTccg9HTV3RVGdPJFny0IAlotfJ/KwHg9uKG EwVnM1ZG6WHqRn8O/lJodbK5TC1+maSV1sybtDpwk26qCJiUug+BYQVq7qiNCFOBNbMb qfSg== Received: by 10.66.78.198 with SMTP id d6mr39806993pax.61.1351040751289; Tue, 23 Oct 2012 18:05:51 -0700 (PDT) Received: from [10.1.10.22] (c-69-181-105-205.hsd1.ca.comcast.net. [69.181.105.205]) by mx.google.com with ESMTPS id ty4sm8522071pbc.57.2012.10.23.18.05.46 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 23 Oct 2012 18:05:49 -0700 (PDT) Content-Type: text/plain; charset=iso-8859-1 Mime-Version: 1.0 (Mac OS X Mail 6.2 \(1499\)) Subject: Re: BUG #7620: array_to_json doesn't support heterogeneous arrays From: Greg Hazel In-Reply-To: Date: Tue, 23 Oct 2012 18:05:44 -0700 Cc: pgsql-bugs@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Merlin Moncure X-Mailer: Apple Mail (2.1499) X-Pg-Spam-Score: -2.7 (--) X-Archive-Number: 201210/213 X-Sequence-Number: 34513 On Oct 23, 2012, at 6:03 PM, Merlin Moncure wrote: > On Tue, Oct 23, 2012 at 6:32 PM, wrote: >> The following bug has been logged on the website: >>=20 >> Bug reference: 7620 >> Logged by: Greg Hazel >> Email address: ghazel@gmail.com >> PostgreSQL version: 9.2.1 >> Operating system: Amazon Linux >> Description: >>=20 >> array_to_json(ARRAY['foo', 100, true]) complains because arrays can't = have >> mixed types, but json arrays can. >>=20 >> So, it's not possible to form a heterogeneous json array, when this = is often >> desired. >=20 > This is not really a bug because the feature is working as intended. > Postgres arrays are homogonous so what you're asking really isn't > possible. You can though use row_to_json to work around: >=20 > select row_to_json(row('foo', 100, true)); That doesn't produce the same results. Call it a feature request or a bug report, the postgres json support = fails to make the json I need. -Greg