Array_to_json remove brackets

Started by Leonardo M. Raméover 10 years ago3 messagesgeneral
Jump to latest
#1Leonardo M. Ramé
l.rame@griensu.com

Hi, is there a way to get an array converted to json without brackets?.

I'm getting, for example [{"field": "value"}, {"field": "value"}] and I
want to get this: {"field": "value"}, {"field": "value"}.

Regards,

--
Leonardo M. Ram�
http://leonardorame.blogspot.com

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Merlin Moncure
mmoncure@gmail.com
In reply to: Leonardo M. Ramé (#1)
Re: Array_to_json remove brackets

On Fri, Nov 13, 2015 at 7:20 AM, Leonardo M. Ramé <l.rame@griensu.com> wrote:

Hi, is there a way to get an array converted to json without brackets?.

I'm getting, for example [{"field": "value"}, {"field": "value"}] and I want
to get this: {"field": "value"}, {"field": "value"}.

please supply an example. Also,
{"field": "value"}, {"field": "value"}

is not valid json, so, basically, no. But you could textually remove
them I guess but I'm thinking more context is needed to give a better
answer.

merlin

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Leonardo M. Ramé
l.rame@griensu.com
In reply to: Merlin Moncure (#2)
Re: Array_to_json remove brackets

El 13/11/15 a las 10:49, Merlin Moncure escribió:

On Fri, Nov 13, 2015 at 7:20 AM, Leonardo M. Ramé <l.rame@griensu.com> wrote:

Hi, is there a way to get an array converted to json without brackets?.

I'm getting, for example [{"field": "value"}, {"field": "value"}] and I want
to get this: {"field": "value"}, {"field": "value"}.

please supply an example. Also,
{"field": "value"}, {"field": "value"}

is not valid json, so, basically, no. But you could textually remove
them I guess but I'm thinking more context is needed to give a better
answer.

merlin

Thanks, I fixed this with a simple trim command:

select trim('[abcd]', '[]');

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general