Using json_populate_recordset without creating a table? Using json_populate_recordset without creating a table? sql sql

Using json_populate_recordset without creating a table?


You have to create a new type to pass to the function (note that as the json_populate returns a json_type you have to use (row).* notation to get individual fields):

CREATE type json_type AS (x1 int, x2 int); SELECT id, (json_populate_recordset(null::json_type, json_records)).* FROM my_table;


Here is another example using a json string on PostgreSQL 11

drop TYPE json_test;create TYPE json_test AS (id_item int, id_menu varchar(100));select * from json_populate_recordset(null::json_test,'[{"id_item":1,"id_menu":"34"},{"id_item":2,"id_menu":"35"}]')