Re: cant get what I want from array_to_json (simple)

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: cant get what I want from array_to_json (simple)
Дата
Msg-id CAKFQuwaH7RS=v7rWu8XCNJwoC6Y4nrqo9aqiYtoFjR-Ze2ivXA@mail.gmail.com
обсуждение исходный текст
Ответ на cant get what I want from array_to_json (simple)  (Michael Moore <michaeljmoore@gmail.com>)
Ответы Re: cant get what I want from array_to_json (simple)  (Michael Moore <michaeljmoore@gmail.com>)
Список pgsql-sql
On Wed, Dec 16, 2015 at 2:23 PM, Michael Moore <michaeljmoore@gmail.com> wrote:
CREATE TYPE key_value_pair AS
   (key text,
    value text);

DO $$declare
   arr qsn_app.key_value_pair[]; 
   pcolumn_values_i json;
begin
  arr[0]  := ('this','that');
  arr[1]  := ('another','one');
  pcolumn_values_i := array_to_json( arr );
  RAISE NOTICE '#1 %', pcolumn_values_i;
end$$;

the 'NOTICE' shows:
NOTICE:  #1 [{"key":"this","value":"that"},{"key":"another","value":"one"}]
what I want to see is:
NOTICE:  #1 {"this":"that","another":"one"}



​The "json(_build)_object​()" functions seems like they better match your need.


David J.

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

Предыдущее
От: Michael Moore
Дата:
Сообщение: cant get what I want from array_to_json (simple)
Следующее
От: britt_mcclafferty
Дата:
Сообщение: Help with complicated query (total SQL newb!)