Re: Malformed array literal in goin from jsonb to real[]

From: Erik Wienhold <ewie(at)ewie(dot)name>
To: Wells Oliver <wells(dot)oliver(at)gmail(dot)com>, pgsql-admin <pgsql-admin(at)postgresql(dot)org>
Subject: Re: Malformed array literal in goin from jsonb to real[]
Date: 2023-03-09 16:12:57
Message-ID: 59706540.193641.1678378377504@office.mailbox.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

> On 09/03/2023 17:05 CET Erik Wienhold <ewie(at)ewie(dot)name> wrote:
>
> Use jsonb_populate_record with a custom type:
>
> create type myrec as (col real[][]);
>
> select * from jsonb_populate_record(null::myrec, '{"col":[[0,1],[2,3]]}');
>
> col
> ---------------
> {{0,1},{2,3}}
> (1 row)

I just noticed that it's also possible without a custom type:

select * from jsonb_to_record('{"col":[[0,1],[2,3]]}') as t(col real[]);

--
Erik

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Jwiencek3 2023-03-09 17:49:03 Re: postgresql to Oracle database migration
Previous Message Erik Wienhold 2023-03-09 16:05:56 Re: Malformed array literal in goin from jsonb to real[]