Re: jsonb: unwrapping text

2021-10-28 Thread tomas
On Wed, Oct 27, 2021 at 04:18:20PM -0700, David G. Johnston wrote: > On Wed, Oct 27, 2021 at 11:58 AM wrote: > > > > > I've found out that one can treat a string singleton as if it > > were an array: > > > > foo=# select '"foo"'::jsonb ->> 0; > >?column? > > -- > >foo > > (1

Re: jsonb: unwrapping text

2021-10-27 Thread David G. Johnston
On Wed, Oct 27, 2021 at 11:58 AM wrote: > > I've found out that one can treat a string singleton as if it > were an array: > > foo=# select '"foo"'::jsonb ->> 0; >?column? > -- >foo > (1 row) > > which conveniently returns the right type. My question: can I rely > on that, o

jsonb: unwrapping text

2021-10-27 Thread tomas
Hi, I'm trying to extract text from a jsonb 'string'. Simply casting gives me the string wrapped in quotes: foo=# select '"foo"'::jsonb::text; text --- "foo" (1 row) This, of course, makes kind of sense, since it /is/ the JSON's textual representation. What is the canonical wa