| From: | Merlin Moncure <mmoncure(at)gmail(dot)com> |
|---|---|
| To: | ghazel(at)gmail(dot)com |
| Cc: | pgsql-bugs(at)postgresql(dot)org |
| Subject: | Re: BUG #7620: array_to_json doesn't support heterogeneous arrays |
| Date: | 2012-10-24 01:03:32 |
| Message-ID: | CAHyXU0xNBtbHJtFxa9P8rJ+Q6VJku-co6mM=hEzXOTeuosJwdg@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-bugs |
On Tue, Oct 23, 2012 at 6:32 PM, <ghazel(at)gmail(dot)com> wrote:
> The following bug has been logged on the website:
>
> Bug reference: 7620
> Logged by: Greg Hazel
> Email address: ghazel(at)gmail(dot)com
> PostgreSQL version: 9.2.1
> Operating system: Amazon Linux
> Description:
>
> array_to_json(ARRAY['foo', 100, true]) complains because arrays can't have
> mixed types, but json arrays can.
>
> So, it's not possible to form a heterogeneous json array, when this is often
> desired.
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:
select row_to_json(row('foo', 100, true));
merlin
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Greg Hazel | 2012-10-24 01:05:44 | Re: BUG #7620: array_to_json doesn't support heterogeneous arrays |
| Previous Message | ghazel | 2012-10-23 23:32:38 | BUG #7620: array_to_json doesn't support heterogeneous arrays |