Re: json_to_recordset not working with camelcase json keys - Mailing list pgsql-bugs

From Joe Conway
Subject Re: json_to_recordset not working with camelcase json keys
Date
Msg-id 56709F85.1040003@joeconway.com
Whole thread Raw
In response to json_to_recordset not working with camelcase json keys  (Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>)
Responses Re: json_to_recordset not working with camelcase json keys  (Daniel Kellenberger <Daniel.Kellenberger@netcetera.com>)
List pgsql-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.
>=20
> Testcase: (PostgreSQL 9.4.5)
>=20
> select * from
> json_to_recordset('[{"aB":1,"bC":"foo"},{"aB":"2","cD":"bar"}]') as x(a=
B
> 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

--=20
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development

pgsql-bugs by date:

Previous
From: Daniel Kellenberger
Date:
Subject: json_to_recordset not working with camelcase json keys
Next
From: Alvaro Herrera
Date:
Subject: Re: BUG #13666: REASSIGN OWNED BY doesn't affect the relation underlying composite type