0

I'm unable to find a way to rename a key in a JSONB. The json I have is the following:

{"array": ["value1", "value2", "value3"], "moneyJavaObject": {"amount": 100.0, "currency":"EUR"}}

I am trying to rename the "amount" key to -> "value". Thank you in advance!

I tried queries like this:

update example
set values = values - 'moneyJavaObject'->'amount' || jsonb_build_object('value', values->'moneyJavaObject'->'amount')
where values is not null
  and values ->> 'moneyJavaObject' <> 'null';```

but no luck
Vos
  • 41
  • 5

0 Answers0