JSONB_PATH_QUERY
Gets values out of JSON with an SQL/JSON path expression — including with conditions.
Syntax
JSONB_PATH_QUERY(<json>, '<path>')
JSONB_PATH_QUERY_FIRST(<json>, '<path>')
JSONB_PATH_EXISTS(<json>, '<path>')
A path starts with $ — the whole document. Then .<key> moves to a field, [*] to all the elements of an array, and ? (@.price > 100) filters by a condition. Every value found becomes a separate row of the result. JSONB_PATH_QUERY_FIRST returns only the first one, and JSONB_PATH_EXISTS says whether anything was found.