I started exploring json in postgresql. I have below jsonb in table.
'{
"Owner":[
{
"Edgeid":4,
"Weight":40,
"EdgeColor":"Black"
},
{
"Edgeid":1,
"Weight":10,
"EdgeColor":"Black"
},
{
"Edgeid":2,
"Weight":20,
"EdgeColor":"Black"
}
],
"Supporter":[
{
"Edgeid":3,
"Weight":30,
"EdgeColor":"Red"
}
]
}'
i am using below code to unnest "Owner" & "Supporter" into different columns
SELECT column_name::JSONB -> 'Owner' AS owner_property,
column_name::JSONB -> 'Supporter' AS supporter_property
FROM table_name;
now suppose if i need to nesting it back to normal like above mentioned json from the two separate column. what would be my code.
Thanks in Advance.