| From: | Andreas Joseph Krogh <andreas(at)visena(dot)com> |
|---|---|
| To: | pgsql-general(at)lists(dot)postgresql(dot)org |
| Subject: | Getting json-value as varchar |
| Date: | 2022-01-06 12:28:26 |
| Message-ID: | VisenaEmail.2e.372da85b7b7aed09.17e2f59771e@tc7-visena |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi, in PG-14 this query returns "value" (with double-quotes):
SELECT ('{"key":"value"}'::jsonb)['key'];
┌─────────┐
│ jsonb │
├─────────┤
│ "value" │
└─────────┘
(1 row)
and this returns 'value' (without the quotes):
SELECT ('{"key":"value"}'::jsonb)->> 'key';
┌──────────┐
│ ?column? │
├──────────┤
│ value │
└──────────┘
(1 row)
How to I use the subscript syntax and get the result as varchar instead of
JSONB, assuming Iknow the JSON-field is a String?
--
Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
www.visena.com <https://www.visena.com>
<https://www.visena.com>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Thomas Markus | 2022-01-06 12:31:19 | Re: Getting json-value as varchar |
| Previous Message | Michael Paquier | 2022-01-06 08:20:27 | Re: md5 issues Postgres14 on OL7 |