json function question

Поиск
Список
Период
Сортировка
От Dan S
Тема json function question
Дата
Msg-id CAPpdape1SieipHCyZVbgtkb5NaD00FKGjiEoqfYj=Pi+9ffisg@mail.gmail.com
обсуждение исходный текст
Ответы Re: json function question  ("David G. Johnston" <david.g.johnston@gmail.com>)
Re: json function question  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
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 take records from table test convert them to json and immediately repopulate them back into records of type test, but it fails with this message:

ERROR:  malformed array literal: "["abc","def","fgh"]"
DETAIL:  "[" must introduce explicitly-specified array dimensions.
********** Error **********

ERROR: malformed array literal: "["abc","def","fgh"]"
SQL state: 22P02
Detail: "[" must introduce explicitly-specified array dimensions.

Is it a bug or how am I supposed to use the populate function ?
If I try an equivalent example with hstore it works well.

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, json_populate_record(null::test, j)
from
(
    select to_json(t) as j from test t
) r


Best Regards
Dan S

В списке pgsql-general по дате отправления:

Предыдущее
От: Pavel Stehule
Дата:
Сообщение: Re: PostgreSQL flavors
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: json function question