Re: JSON for PG 9.2

Поиск
Список
Период
Сортировка
От Merlin Moncure
Тема Re: JSON for PG 9.2
Дата
Msg-id CAHyXU0zJG+wDR6BYQfxUoz14NirKaaR2teXQLDwxZSE7G+tTXA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: JSON for PG 9.2  (Josh Berkus <josh@agliodbs.com>)
Ответы Re: JSON for PG 9.2  (Andrew Dunstan <andrew@dunslane.net>)
Список pgsql-hackers
On Tue, Jan 31, 2012 at 12:15 PM, Josh Berkus <josh@agliodbs.com> wrote:
> Andrew,
>
>> based on Abhijit's feeling and some discussion offline, the consensus
>> seems to be to remove query_to_json.
>
> If we do that, what would getting complete query results back from a
> query look like?  It's important to make this as simple for developers
> as possible.

two options:
1. row_to_json(rowvar)
SELECT row_to_json(foo) from foo;
SELECT row_to_json(row(a,b,c)) from foo;

2. array_to_json(array_agg()/array())
SELECT array_to_json(array(select foo from foo));
SELECT array_to_json(array[1,2,3]);

#1 I expect will be the more used version -- most json handling client
side api (for example node.js drivers) are optimized for row by row
processing, but via #2 you can stuff a whole query into single json
object if you're so inclined.

merlin


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

Предыдущее
От: Abhijit Menon-Sen
Дата:
Сообщение: Re: JSON for PG 9.2
Следующее
От: Robert Haas
Дата:
Сообщение: Re: Issues with C++ exception handling in an FDW