Q:

unpack JSONB object with best performance

There are a simple expression or function to "unpack" sub-objects, exploding it into the main object?

Explaining with example:
SELECT '{"x":null,"A":{"foo":true,"bar":123},"B":2332}'::jsonb;  
-- = JSONB object with "A" as sub-object.

Is a typical case: I need "A" content into the main object. And need that datatypes (number/boolean/null) are preserved, no "convert string solution" is valid. Also good perfomance is expected.
Remove "A" is ok with - 'A', but, put back its contents , is not easy:
SELECT ('{"x":null,"A":{"foo":true,"bar":123},"B":2332}'::jsonb - 'A')
    || '{"foo":true,"bar":123}'::jsonb; -- aim result, unpacked!

SELECT ('{"x":null,"A":{"foo":true,"bar":123},"B":2332}'::jsonb - 'A')
    || ('{"A":{"foo":true,"bar":123}}'::jsonb)->'A' -- NOT WORKS...

How to put back "A" contents?

A:

Operator || has higher priority than operator ->, so you need to move the parentheses around. I only changed the last from ::jsonb)->'A' to ::jsonb->'A') and it works:
SELECT 
    ('{"x":null,"A":{"foo":true,"bar":123},"B":2332}'::jsonb - 'A')
    || ('{"A":{"foo":true,"bar":123}}'::jsonb->'A');

