Search Postgresql Archives

Re: jsonb: unwrapping text

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 27, 2021 at 11:58 AM <tomas@xxxxxxxxxx> 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, or am I missing a much more obvious option?


Not sure if this exact behavior is trustworthy - but you are on the right path. Place the value into either a json array or json object and then use the text versions of the accessor methods to get the json value to pass through the decoding routine.

David J.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]

  Powered by Linux