BUG #13160: Incorrect escaping of quotes in JSON export

From: me(at)andrewray(dot)me
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #13160: Incorrect escaping of quotes in JSON export
Date: 2015-04-25 19:53:13
Message-ID: 20150425195313.2561.68542@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 13160
Logged by: Andy
Email address: me(at)andrewray(dot)me
PostgreSQL version: 9.3.5
Operating system: OSX
Description:

Postgres escapes quotes incorrectly when creating a JSON export.

UPDATE models SET column='"hello"' WHERE id=1;

COPY (SELECT row_to_json(models)
FROM (SELECT column FROM shaders WHERE id=1) shaders)
TO '/output.json';

The contents of output.json:

{"column":"\\"hello\\""}

You can see that the quotes are escaped improperly and it creates invalid
JSON.
It should be:

{"column":"\"hello\""}

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2015-04-25 21:05:48 Re: BUG #13126: table constraint loses its comment
Previous Message Patrice Drolet 2015-04-25 18:31:51 Re: BUG #13143: Cannot stop and restart a streaming server with a replication slot