json

jsonb_to_record

Converts an object into a record with caller-declared column types; absent fields become SQL NULL.

Formal Syntax & Structure

sql syntaxsql
jsonb_to_record(jsonb) AS alias(column type, ...)

Working Example

Example Snippetsql
SELECT * FROM jsonb_to_record('{"id":7}') AS t(id int, label text);
SQL Reference