Expands the top-level JSON object to a row having the composite type of the base argument.
Signatures & examples
jsonb_populate_record ( base anyelement, from_json jsonb ) → anyelement
Expands the top-level JSON object to a row having the composite type of the base argument. The JSON object is scanned for fields whose names match column names of the output row type, and their values are inserted into those columns of the output. (Fields that do not correspond to any output column name are ignored.) In typical use, the value of base is just NULL, which means that any output columns that do not match any object field will be filled with nulls. However, if base isn't NULL then the values it contains will be used for unmatched columns.
select * from json_populate_record(null::myrowtype, '{"a": 1, "b": ["2", "a b"], "c": {"d": 4, "e": "a b c"}, "x": "foo"}') → a | b | c
---+-----------+-------------
1 | {2,"a b"} | (4,"a b c")