using initcap function on a json with an list of strings postgresql

Viewed 22

I am trying to use the initcap to capitalize the first letter of the string in a list of strings of json type

enter image description here

The table looks like this.

I tried this first

update smfood set category = to_json(string_to_array(INITCAP(category::text),','))
where smfood.category is not null

but the results get me these slashes

enter image description here

any idea on how i can use initcap to capitalize the first letter in a json list of strings?

1 Answers

Do it like this

update smfood set category = INITCAP(category::text)::json
where smfood.category is not null;
Related