Re: Building JSON objects - Mailing list pgsql-general

From Szymon Guz
Subject Re: Building JSON objects
Date
Msg-id CAFjNrYtzjSZwoG+cM2wZHcinSrAPxwQGd8Yi0EY82ipRZaX7Bw@mail.gmail.com
Whole thread Raw
In response to Re: Building JSON objects  (Eli Murray <ejmurra2@illinimedia.com>)
List pgsql-general


On 27 March 2015 at 19:12, Eli Murray <ejmurra2@illinimedia.com> wrote:
I'm running psql --version 9.4.1

Also, it may be worth noting that rawdata.deptname and rawdata.deptcode are both text data types.

The errors I'm getting are: 

ERROR:  syntax error at or near "json_build_object"
LINE 1: insert into json(data) json_build_object(SELECT DISTINCT dep...

and

ERROR:  syntax error at or near "row_to_json"
LINE 1: insert into json(data) row_to_json(SELECT DISTINCT deptname,...


Yea, because the insert syntax is a little bit different, try this:

insert into json(data) SELECT json_build...
or
insert into json(data) SELECT row_to_json...

regards,
Szymon

pgsql-general by date:

Previous
From: Merlin Moncure
Date:
Subject: Re: json-patch support?
Next
From: Adrian Klaver
Date:
Subject: Re: Building JSON objects