retrieve subset of a jsonb object with a list of keys - Mailing list pgsql-general

From Tom Smith
Subject retrieve subset of a jsonb object with a list of keys
Date
Msg-id CAKwSVFHk+m16ouvymp1mMPq4LU1hpdFhJ-=05nU3kumdPxx4-w@mail.gmail.com
Whole thread Raw
Responses Re: retrieve subset of a jsonb object with a list of keys
List pgsql-general
Hi:

I have a jsonb columne with json object like belo
{"a": 1, "b":2, "c":3}

I'd like to get subset of the object with key list ["a","c"]
so it retruns json object of

{"a": 1,  "c":3}

something like

select '{"a": 1, "b":2, "c":3}'::jsob ->'["a","c"]'

what would be the most efficient (and simplest if possible) to get the subset with the key list?

Thanks

pgsql-general by date:

Previous
From: Michael H
Date:
Subject: Re: CentOS - PostgreSQL 9.2.13 -> 9.4
Next
From: Chris Mair
Date:
Subject: Re: retrieve subset of a jsonb object with a list of keys