SELECT
sku,
jsonb_object_agg(warehouse_name, (warehouse_data->>'stock')::int) AS warehouses,
additional_info
FROM (
SELECT
sku,
warehouse_name,
warehouse_data,
additional_info
FROM
products,
jsonb_each(warehouses) AS warehouse(warehouse_name, warehouse_data)
) AS expanded
GROUP BY sku
Reading the documentation, I found the answer with the function of jsonb_each, which gives me the key and the value from the column of warehouse.