Re: json select question - Mailing list pgsql-general

From John R Pierce
Subject Re: json select question
Date
Msg-id 3f9679b6-1a6b-b9b2-d387-cb6b31c3d604@hogranch.com
Whole thread Raw
In response to json select question  (CS DBA <cs_dba@consistentstate.com>)
List pgsql-general
On 9/21/2016 4:54 PM, CS DBA wrote:
How can i pull a unique list of all json column names? such as book_name, catalog_name, etc

try json_object_keys() ... https://www.postgresql.org/docs/current/static/functions-json.html

but this will only pull the top level keys, like (from the first row of your example) , book_name, author... it won't pull out any second level fields like first_name, last_name.

you'll likely need to run this on all rows, and do a group by to get what you need.

thats a pretty messy way of storing data, btw, and not very relational, having a key name indicate a record type, and tossing all the record types into the same table.


-- 
john r pierce, recycling bits in santa cruz

pgsql-general by date:

Previous
From: Patrick B
Date:
Subject: Re: overwrite column data select - Postgres 9.2
Next
From: Tom Lane
Date:
Subject: Re: Unstable C Function