Extract data from JSONB

From: Alex Magnum <magnum11200(at)gmail(dot)com>
To: Postgres General <pgsql-general(at)postgresql(dot)org>
Subject: Extract data from JSONB
Date: 2016-08-08 03:08:08
Message-ID: CA+cR4zdTKZDVbd7L+Ymm=6byXBw8DbPQfbqUg==W7fE944Yh-Q@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,
I need some help with extracting data from json.

I have the following jsonb field

modules
{
"accounts": {"status": true},
"admin": {"status": true},
"calendar": {"status": false},
"chat": {"status": true},
"contacts": {"status": true},
"dashboard": {"status": false},
"help": {"status": true}
}

How can I convert that into one row each based on status; for example if I
only want to have the active modules.

Only true

module | status
----------+-------
accounts | true
admin | true
contacts | true
help | true

Thanks for any advise

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Paquier 2016-08-08 03:23:38 Re: Extract data from JSONB
Previous Message Sandeep Gupta 2016-08-08 03:03:25 Re: how to serialize insert followed by read(select) by different clients