From: Joe Conway <mail@joeconway.com>
To: Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>
To: pgsql-bugs@postgresql.org <pgsql-bugs@postgresql.org>
Subject: Re: json_to_recordset not working with camelcase json keys
Date: Tue, 15 Dec 2015 15:17:25 -0800
Message-ID: <56709F85.1040003@joeconway.com> (raw)
In-Reply-To: <9e4b92c2c68d4c3b8c4cdf5aa11bc844@exchange01.one.nca>
References: <9e4b92c2c68d4c3b8c4cdf5aa11bc844@exchange01.one.nca>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>
On 12/15/2015 01:46 PM, Daniel Kellenberger wrote:
> We tried to extract from a json with camel case keys values, but
> unfortunatelly they are not mapped.
>
> Testcase: (PostgreSQL 9.4.5)
>
> select * from
> json_to_recordset('[{"aB":1,"bC":"foo"},{"aB":"2","cD":"bar"}]') as x(aB
> int, bC text);
Not a bug, I believe. You probably meant this:
select * from json_to_recordset('[{"aB":1,"bC":"foo"},
{"aB":"2","cD":"bar"}]')
as x("aB" int, "bC" text, "cD" text);
aB | bC | cD
----+-----+-----
1 | foo |
2 | | bar
(2 rows)
Unquoted identifiers are lowercased in postgres, so for camel case
identifiers you would need double quotes.
HTH,
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
Attachments:
signature.asc (application/pgp-signature, 835B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: mail@joeconway.com, Daniel.Kellenberger@netcetera.com
Subject: Re: json_to_recordset not working with camelcase json keys
In-Reply-To: <56709F85.1040003@joeconway.com>
References: <9e4b92c2c68d4c3b8c4cdf5aa11bc844@exchange01.one.nca> <56709F85.1040003@joeconway.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox