I have a numeric column total_price and I want to move it to a jsonb property named price_detail. For example, if the total_price value is 1000, the expected price_detail value is {"totalPrice": 1000}
I've tried using jsonb_set but the result is empty object {}
UPDATE public.orders SET price_detail =
jsonb_set('{}'
, '{}'
, jsonb_build_object('totalPrice', total_price::numeric))
If I set the path,
UPDATE public.orders SET price_detail =
jsonb_set('{}'
, '{totalPrice}'
, jsonb_build_object('totalPrice', total_price::numeric))
The result is {"totalPrice":{"totalPrice":1000}} which is unexpected
How can I set the totalPrice property correctly?