pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
BUG #9168: Invalid JSON output generated by SQL statement
2+ messages / 2 participants
[nested] [flat]

* BUG #9168: Invalid JSON output generated by SQL statement
@ 2014-02-10 08:19 garyjob@krake.io
  2014-02-10 16:44 ` Re: BUG #9168: Invalid JSON output generated by SQL statement Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: garyjob@krake.io @ 2014-02-10 08:19 UTC (permalink / raw)
  To: pgsql-bugs

The following bug has been logged on the website:

Bug reference:      9168
Logged by:          Gary Teh
Email address:      garyjob@krake.io
PostgreSQL version: 9.2.2
Operating system:   MacOS X 10.7.5
Description:        

Statement to create the database table
===
CREATE TABLE test_tables (
    properties hstore,
    "pingedAt" timestamp with time zone,
    id integer NOT NULL,
    "createdAt" timestamp with time zone NOT NULL,
    "updatedAt" timestamp with time zone NOT NULL
);

Statement to create a record
===
INSERT INTO 
"test_tables" 
("createdAt","updatedAt","pingedAt","properties") VALUES
('2014-2-10 0:10:28','2014-2-10 0:10:28','2014-2-10 0:10:28','"drug bank" =>
"cache \"that stuff"')

Statement to export the record into a JSON file
===
Copy (
  select 
    array_to_json(
      array_agg( row_to_json(row)
    )
  ) 
  from (
    SELECT 
      properties::hstore->'drug bank' as "drug bank",
      "pingedAt" 
    FROM 
      "test_tables" 
    WHERE true
  ) row 
) To '/tmp/invalid_json_output'

The invalid JSON output
[{
  "drug bank":"cache \\"that stuff",
  "pingedAt":"2014-02-09 16:10:28-08"
},{
  "drug bank":"cache \\"that stuff",
  "pingedAt":"2014-02-10 00:10:28-08"
}]

The final JSON output is not valid.


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: BUG #9168: Invalid JSON output generated by SQL statement
  2014-02-10 08:19 BUG #9168: Invalid JSON output generated by SQL statement garyjob@krake.io
@ 2014-02-10 16:44 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2014-02-10 16:44 UTC (permalink / raw)
  To: garyjob@krake.io; +Cc: pgsql-bugs

garyjob@krake.io writes:
> The invalid JSON output
> [{
>   "drug bank":"cache \\"that stuff",
>   "pingedAt":"2014-02-09 16:10:28-08"
> },{
>   "drug bank":"cache \\"that stuff",
>   "pingedAt":"2014-02-10 00:10:28-08"
> }]

> The final JSON output is not valid.

Hmm, I can't claim to have memorized the JSON spec, but that looks
generally sane to me.  What do you think is invalid about it, exactly?

(If you're complaining about the backslash having been doubled, that's
an effect of the COPY, not a bug in the JSON output function.)

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-02-10 16:44 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-02-10 08:19 BUG #9168: Invalid JSON output generated by SQL statement garyjob@krake.io
2014-02-10 16:44 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox