Re: Getting json-value as varchar

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Getting json-value as varchar
Date: 2022-01-06 13:20:23
Message-ID: VisenaEmail.39.5eee7254b64bd194.17e2f89cd27@tc7-visena
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


På torsdag 06. januar 2022 kl. 14:13:40, skrev David G. Johnston <
david(dot)g(dot)johnston(at)gmail(dot)com <mailto:david(dot)g(dot)johnston(at)gmail(dot)com>>: On Thursday,
January 6, 2022, Andreas Joseph Krogh <andreas(at)visena(dot)com
<mailto:andreas(at)visena(dot)com>> wrote:

I think you misread my message. What I want is for the subscript-version:
('{"key":"value"}'::jsonb)['key']
to return:

┌──────────┐
│ ?column? │
├──────────┤
│ value │
└──────────┘

instead of

┌─────────┐
│ jsonb │
├─────────┤
│ "value" │
└─────────

A given syntax/operator can only return one thing so what you want is
fundamentally not possible.

That's not very helpful....
Apparently I'm after a solution which either casts this to varchar or a
function that takes JSONB as argument and outputs the first field-value as
varchar.

--
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>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Markus 2022-01-06 13:25:16 Re: Getting json-value as varchar
Previous Message Andreas Joseph Krogh 2022-01-06 13:17:36 Sv: Recommended storage hardware