Is it possible to do something like this in Postgres:
do $$
declare
v_key text;
v_json jsonb;
begin
v_key := 'id';
v_json := jsonb_build_object(
'id', jsonb_build_object('nest_id',1)
);
raise notice '%', v_json #> '{'||v_key||'}'->>'nest_id';
end$$
ERROR: operator does not exist: jsonb #> text
No operator matches the given name and argument type(s). You might need to add explicit type casts.
'{'||v_key||'}'::jsonb