Re: [GENERAL] json function question

2016-02-24 Thread Andrew Dunstan
On 02/24/2016 09:41 AM, Tom Lane wrote: However, it looks to me like row_to_json already does pretty much the right thing with nested array/record types: regression=# select row_to_json(row(1,array[2,3],'(0,1)'::int8_tbl,array[(1,2),(3,4)]::int8_tbl[])); r

Re: [GENERAL] json function question

2016-02-24 Thread David G. Johnston
On Wednesday, February 24, 2016, Andrew Dunstan wrote: > > > On 02/24/2016 09:11 AM, David G. Johnston wrote: > >> On Wednesday, February 24, 2016, Andrew Dunstan > > wrote: >> >> >> Having json(b)_populate_record recursively process nested complex >> objects w

Re: [GENERAL] json function question

2016-02-24 Thread Tom Lane
"David G. Johnston" writes: > On Wednesday, February 24, 2016, Andrew Dunstan wrote: >> Having json(b)_populate_record recursively process nested complex objects >> would be a large undertaking. One thing to consider is that json arrays are >> quite different from Postgres arrays: they are essent

Re: [GENERAL] json function question

2016-02-24 Thread Andrew Dunstan
On 02/24/2016 09:11 AM, David G. Johnston wrote: On Wednesday, February 24, 2016, Andrew Dunstan > wrote: Having json(b)_populate_record recursively process nested complex objects would be a large undertaking. One thing to consider is that json arrays a

Re: [GENERAL] json function question

2016-02-24 Thread David G. Johnston
On Wednesday, February 24, 2016, Andrew Dunstan wrote: > > > Having json(b)_populate_record recursively process nested complex objects > would be a large undertaking. One thing to consider is that json arrays are > quite different from Postgres arrays: they are essentially one-dimensional > hetero

Re: [GENERAL] json function question

2016-02-24 Thread Andrew Dunstan
On 02/23/2016 02:54 PM, Tom Lane wrote: Dan S writes: I have this table, data and query: create table test ( id int, txt text, txt_arr text[], f float ); insert into test values (1,'jkl','{abc,def,fgh}',3.14159),(2,'hij','{abc,def,fgh}',3.14159),(2,null,null,null),(3,'def'

Re: [GENERAL] json function question

2016-02-23 Thread Merlin Moncure
On Tue, Feb 23, 2016 at 1:54 PM, Tom Lane wrote: > Dan S writes: >> I have this table, data and query: > >> create table test >> ( >> id int, >> txt text, >> txt_arr text[], >> f float >> ); > >> insert into test >> values >> (1,'jkl','{abc,def,fgh}',3.14159),(2,'hij','{abc,def,fg

Re: [GENERAL] json function question

2016-02-23 Thread Dan S
Yes I meant equivalence in the roundtrip conversion sense. And of course the "feature complete" solution which can handle deep structures would be really nice to have. Best Regards Dan S 2016-02-23 21:11 GMT+01:00 David G. Johnston : > On Tue, Feb 23, 2016 at 12:54 PM, Tom Lane wrote: > >> Dan

Re: [GENERAL] json function question

2016-02-23 Thread David G. Johnston
On Tue, Feb 23, 2016 at 12:54 PM, Tom Lane wrote: > Dan S writes: > > I have this table, data and query: > > > create table test > > ( > > id int, > > txt text, > > txt_arr text[], > > f float > > ); > > > insert into test > > values > > > (1,'jkl','{abc,def,fgh}',3.14159),(2,'hi

Re: [GENERAL] json function question

2016-02-23 Thread Tom Lane
Dan S writes: > I have this table, data and query: > create table test > ( > id int, > txt text, > txt_arr text[], > f float > ); > insert into test > values > (1,'jkl','{abc,def,fgh}',3.14159),(2,'hij','{abc,def,fgh}',3.14159),(2,null,null,null),(3,'def',null,0); > select j, js

Re: [GENERAL] json function question

2016-02-23 Thread David G. Johnston
On Tue, Feb 23, 2016 at 12:12 PM, Dan S wrote: > Hi ! > > I'm running "PostgreSQL 9.5.1 on i686-pc-linux-gnu, compiled by > gcc-4.4.real (Debian 4.4.5-8) 4.4.5, 32-bit" > > I'm trying out json functions and stumbled on a problem with > json_populate_record. > To try out the function I decided to