|
|
|
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, 16:13 |
|
||
|
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 ... |
|||
|
:
Нравится:
Не нравится:
|
|||
| 25.03.2016, 18:01 |
|
||
|
|

start [/forum/topic.php?fid=53&gotonew=1&tid=1997328]: |
0ms |
get settings: |
6ms |
get forum list: |
16ms |
check forum access: |
3ms |
check topic access: |
3ms |
track hit: |
31ms |
get topic data: |
9ms |
get first new msg: |
6ms |
get forum data: |
3ms |
get page messages: |
41ms |
get tp. blocked users: |
1ms |
| others: | 203ms |
| total: | 322ms |

| 0 / 0 |
