
Новые сообщения [новые:0]
Дайджест
Горячие темы
Избранное [новые:0]
Форумы
Пользователи
Статистика
Статистика нагрузки
Мод. лог
Поиск
|
|
25.03.2016, 16:13
|
|||
|---|---|---|---|
|
|||
array_agg to correct json |
|||
|
#18+
Все привет. Подскажите, может быть у кого-нибудь был опыт с json в pg. Запрос: select account, bannerid, array_agg((t.event_type, t.amount) order by t.event_type) as events from events t group by account, bannerid Поле events получается таким: {"(rich-100p,1)","(rich-25p,1)","(rich-50p,1)","(rich-75p,1)"} Если попытаться конвертнуть в json, то получим запись в виде: [{"f1":"dich-100p","f2":1},{"f1":"dich-25p","f2":1},{"f1":"dich-50p","f2":1},{"f1":"dich-75p","f2":1}] Не совсем понятно откуда здесь появляются поля f1,f2. В идеале хотелось бы key:value {"dich-100p":1,"dich-25p":1} ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|
25.03.2016, 18:01
|
|||
|---|---|---|---|
|
|||
array_agg to correct json |
|||
|
#18+
oracle_adm, http://www.postgresql.org/docs/current/static/functions-aggregate.html * aggregates values as a JSON array * aggregates name/value pairs as a JSON object ... |
|||
|
:
Нравится:
Не нравится:
|
|||
|
|
|

start [/forum/topic.php?fid=53&mobile=1&tid=1997328]: |
0ms |
get settings: |
8ms |
get forum list: |
16ms |
check forum access: |
4ms |
check topic access: |
4ms |
track hit: |
195ms |
get topic data: |
7ms |
get forum data: |
2ms |
get page messages: |
29ms |
get tp. blocked users: |
1ms |
| others: | 231ms |
| total: | 497ms |

| 0 / 0 |
