Re: BUG #8293: There are no methods to convert json scalar text to text in v9.3 beta2

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: jaroslav(dot)potapov(at)gmail(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: BUG #8293: There are no methods to convert json scalar text to text in v9.3 beta2
Date: 2013-08-02 17:04:36
Message-ID: 20130802170436.GB14543@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, Jul 10, 2013 at 07:07:54PM +0000, jaroslav(dot)potapov(at)gmail(dot)com wrote:
> The following bug has been logged on the website:
>
> Bug reference: 8293
> Logged by: Yaroslav Potapov
> Email address: jaroslav(dot)potapov(at)gmail(dot)com
> PostgreSQL version: Unsupported/Unknown
> Operating system: All
> Description:
>
> SELECT '"a\"b"'::json::text
>
>
> returns text: '"a\"b"' ,
> but it must return 'a"b' in my opinion.

I see you didn't get a reply, so let me try. I am no JSON expert, but I
think what is happening is that the system stores "a\"b" because that is
what a JSON/Javascript interpreter would need to understand that value.
It would convert "a\"b" to a"b. If we just stored a"b, the interpreter
would throw an error on input.

You can see this a little bit using 9.3 beta to pull values based on
keys:

SELECT json_extract_path('{"\"a": "b\"c"}'::json, '"a');
json_extract_path
-------------------
"b\"c"
(1 row)

SELECT json_extract_path('{"\"a": "b\"c"}'::json, '\"a');
json_extract_path
-------------------

(1 row)

Notice the key is "a, not \"a.

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ It's impossible for everything to be true. +

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Andrew Dunstan 2013-08-02 18:16:39 Re: BUG #8293: There are no methods to convert json scalar text to text in v9.3 beta2
Previous Message Kevin Grittner 2013-08-02 13:22:17 Re: BUG #8328: Unable to start postgresql on the Debian machine.