Search Postgresql Archives

Re: Extract data from JSONB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Aug 8, 2016 at 12:08 PM, Alex Magnum <magnum11200@xxxxxxxxx> wrote:
> How can I convert that into one row each based on status; for example if I
> only want to have the active modules.

You can use jsonb_each to decompose that:
=# select key, (value::json)->'status' from jsonb_each('{

                                                         "accounts":
  {"status": true},
 "admin":        {"status": true},
"calendar":     {"status": false},
"chat":         {"status": true},
"contacts":     {"status": true},
"dashboard":    {"status": false},
"help":         {"status": true}}'::jsonb);
    key    | ?column?
-----------+----------
 chat      | true
 help      | true
 admin     | true
 accounts  | true
 calendar  | false
 contacts  | true
 dashboard | false
(7 rows)
-- 
Michael


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux