Re: [GENERAL] Building JSON objects

2015-03-27 Thread Adrian Klaver
On 03/27/2015 12:30 PM, Eli Murray wrote: Thanks to you all for the replies. Adrian, your solution is working for me without errors but it's not actually inserting anything. I'll keep fiddling with it and see if I can get what I want but I'm confident now that I'm on the right path. As a backup,

Re: [GENERAL] Building JSON objects

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 12:30 PM, Eli Murray wrote: > Thanks to you all for the replies. Adrian, your solution is working for me > without errors but it's not actually inserting anything. I'll keep fiddling > with it and see if I can get what I want but I'm confident now that I'm on > the right p

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Eli Murray
Thanks to you all for the replies. Adrian, your solution is working for me without errors but it's not actually inserting anything. I'll keep fiddling with it and see if I can get what I want but I'm confident now that I'm on the right path. As a backup, I did what I wanted to in Javascript and wro

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Jan de Visser
On March 27, 2015 11:38:42 AM David G. Johnston wrote: > On Fri, Mar 27, 2015 at 11:31 AM, Jan de Visser wrote: > > On March 27, 2015 01:12:52 PM Eli Murray wrote: > > > ERROR: syntax error at or near "json_build_object" > > > LINE 1: insert into json(data) json_build_object(SELECT DISTINCT dep..

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Adrian Klaver
On 03/27/2015 11:12 AM, Eli Murray 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

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Szymon Guz
On 27 March 2015 at 19:12, Eli Murray 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 jso

Re: [GENERAL] Building JSON objects

2015-03-27 Thread David G. Johnston
On Fri, Mar 27, 2015 at 11:31 AM, Jan de Visser wrote: > On March 27, 2015 01:12:52 PM Eli Murray wrote: > > ERROR: syntax error at or near "json_build_object" > > LINE 1: insert into json(data) json_build_object(SELECT DISTINCT dep... > > You may want to review the syntax of the INSERT command,

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Adrian Klaver
On 03/27/2015 11:12 AM, Eli Murray 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

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Jan de Visser
On March 27, 2015 01:12:52 PM Eli Murray wrote: > ERROR: syntax error at or near "json_build_object" > LINE 1: insert into json(data) json_build_object(SELECT DISTINCT dep... You may want to review the syntax of the INSERT command, i.e. this doesn't have anything to do with JSON: INSERT INTO fo

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Eli Murray
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:

Re: [GENERAL] Building JSON objects

2015-03-27 Thread Adrian Klaver
On 03/27/2015 10:40 AM, Eli Murray wrote: Hi All, I'm trying to create an array of JSON objects from an existing table. I've created a new table: "CREATE TABLE json(data json[]);" Now i need to populate it with key value pairs from another table. I'd like to create the objects to look like: {

[GENERAL] Building JSON objects

2015-03-27 Thread Eli Murray
Hi All, I'm trying to create an array of JSON objects from an existing table. I've created a new table: "CREATE TABLE json(data json[]);" Now i need to populate it with key value pairs from another table. I'd like to create the objects to look like: { "code": rawdata.deptcode, "name": rawdata.d