I need to insert below JSON value into a table which will have two rows as id 1708,1
and 1708,2
:
{
"id":1708,
"types":[1,2]
}
Below is what I have tried:
insert into table(1708,
unnest(array(select json_array_elements_text('{
"id":1708,
"types":[1,2]
}'::json->'types'))
This is complaining for type of types as integer. However, the query also does not look efficient to me. Could someone guide me on how to do this properly?