It looks like your bytea_output is set to 'escape', which would explain
what you are seeing. Try adding this in first:
SET bytea_output = hex;
SELECT JSON_VALUE(jsonb '"AQID"', '$' RETURNING bytea);
That (hex) is the default value, so you must be setting it to escape
somewhere. You can see where by running:
select * from pg_settings where name = 'bytea_output';
Examine the source, sourcefile, and sourceline columns
I personally prefer hex, but perhaps it's set to octet in your system for a
reason. If not, maybe change it globally?
Cheers,
Greg
--
Crunchy Data - https://www.crunchydata.com
Enterprise Postgres Software Products & Tech Support