how to correctly cast json value to text?

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: how to correctly cast json value to text?
Date: 2021-05-03 09:15:08
Message-ID: CAFj8pRB-DdiBWH-e-0WC4VAkDOXW4FdBPBU28c0jAMm4bpf9QA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

I am testing a new subscripting interface for jsonb, and I found one issue.

DO $$
DECLARE v jsonb;
BEGIN
v['a'] = '"Ahoj"';
RAISE NOTICE '%', v['a'];
END;
$$;
NOTICE: "Ahoj"
DO

When I use this interface for reading, the jsonb type is returned. What is
the correct way for casting from jsonb text to text value? I would not
double quotes inside the result. Cast to text doesn't help. For operator
API we can use "->>" symbol. But we have nothing similar for subscript API.

Regards

Pavel

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Pavel Stehule 2021-05-03 09:23:52 Re: how to correctly cast json value to text?
Previous Message Dilip Kumar 2021-05-03 08:15:46 Re: Identify missing publications from publisher while create/alter subscription.