Re: JSON row_to_json_array - Mailing list pgsql-novice

From Tjibbe R
Subject Re: JSON row_to_json_array
Date
Msg-id BLU0-SMTP88643100CD56672B3F447DD2D0@phx.gbl
Whole thread Raw
In response to Re: JSON row_to_json_array  (Luca Ferrari <fluca1978@infinito.it>)
Responses Re: JSON row_to_json_array  (Luca Ferrari <fluca1978@infinito.it>)
Re: JSON row_to_json_array  (Merlin Moncure <mmoncure@gmail.com>)
List pgsql-novice
Yes it would be a simple array, but it costs a lot of coding. Because every item in the array need to be inserted in the function to_json().

Example:

DECLARE
_arr json[];
FOR row in SELECT * FROM persons LOOP
   _arr := array_append (_arr, ARRAY(to_json(row.id), to_json(row.birthdate), to_json (row.active_bool),to_json(row.level)); 
END LOOP;
RETURN to_json(_arr);


On 23 September 2013 08:42, Luca Ferrari <fluca1978@infinito.it> wrote:
On Sat, Sep 21, 2013 at 10:26 PM, Tjibbe R <tjibbe@rijpma.org> wrote:
> Hello,
>
> Why isn't there a row_to_json_array(record) funtion?
>

I'm not a json expert, but it could be the output would not be a json
structure (after all, it would be a simple array)?

Luca

pgsql-novice by date:

Previous
From: Luca Ferrari
Date:
Subject: Re: JSON row_to_json_array
Next
From: Luca Ferrari
Date:
Subject: Re: JSON row_to_json_array