BUG #13160: Incorrect escaping of quotes in JSON export - Mailing list pgsql-bugs

From me@andrewray.me
Subject BUG #13160: Incorrect escaping of quotes in JSON export
Date
Msg-id 20150425195313.2561.68542@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #13160: Incorrect escaping of quotes in JSON export  (Marko Tiikkaja <marko@joh.to>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      13160
Logged by:          Andy
Email address:      me@andrewray.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\""}

pgsql-bugs by date:

Previous
From: Patrice Drolet
Date:
Subject: Re: BUG #13143: Cannot stop and restart a streaming server with a replication slot
Next
From: cees.van.zeeland@xs4all.nl
Date:
Subject: BUG #13168: DROP DATABASE does not clean up all references