0

I have a table T with a column J of type json, and one of it's row contains value

{'SELECTION':'A'}


I want to change it to

{'selection':'A'}

i.e change the key of the JSON.

Any one has experience? I am not able to find any relevant resource.

Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73

1 Answers1

0

Thanks to @Sebastian, I solved it using the documentation https://www.postgresql.org/docs/current/functions-json.html

update T set J = '{"selection":"A"}' where  J::jsonb @> '{"SELECTION":"A"}'::jsonb

Another query that will do same

update T set J = '{"selection":"A"}' where J::json->>'SELECTION'='A'
Akshay Vijay Jain
  • 13,461
  • 8
  • 60
  • 73