I am trying to update the fields age
and city
of one json feed using:
select jsonb_set(d,'{0,age,city}',d || '{"age":30,"city":"los angeles"}')
from (
values ('{"name":"john", "age":26,"city":"new york city"}'::jsonb)
) t(d);
but what I get back is:
{"age": 26, "city": "new york city", "name": "john"}
instead of the expected:
{"age": 30, "city": "los angeles", "name": "john"}
that means none of the wanted fields have been updated.
I have already looked at:
postgres jsonb_set multiple keys update
and went through the relative documentation but I cannot get it right. Any help?