Re: json_to_recordset not working with camelcase json keys

From: Daniel Kellenberger <Daniel(dot)Kellenberger(at)netcetera(dot)com>
To: Joe Conway <mail(at)joeconway(dot)com>, "pgsql-bugs(at)postgresql(dot)org" <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: json_to_recordset not working with camelcase json keys
Date: 2015-12-17 07:56:08
Message-ID: 6f30a05b5a61458aa89c2d9b033aeb1a@exchange01.one.nca
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Hi Joe

Thanks for your answer, this solved our issue.
In one project we are currently switching from Oracle to PostgreSQL and are excited about the database.

Kind regards,
Daniel

--
Our software sets the course: http://nca.me/software

Daniel Kellenberger | daniel(dot)kellenberger(at)netcetera(dot)com | T +41 44 297 58 14 |
Netcetera AG | 8040 Zürich | Switzerland | http://netcetera.com |

________________________________________
Von: Joe Conway <mail(at)joeconway(dot)com>
Gesendet: Mittwoch, 16. Dezember 2015 00:17
An: Daniel Kellenberger; pgsql-bugs(at)postgresql(dot)org
Betreff: Re: [BUGS] json_to_recordset not working with camelcase json keys

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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Marcin Sieńko 2015-12-17 08:53:21 Re: BUG #13817: Query planner strange choose while select/count small part of big table - complete
Previous Message Alvaro Herrera 2015-12-16 23:15:31 Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type