postgresql update json field code example
Example 1: update json in postgres
[{“type”: “phone”, “value”: “+1–202–555–0105”}, {“type”: “email”, “value”: “jimi.hendrix@gmail.com”}]
[{“type”: “email”, “value”: “janis.joplin@gmail.com”}]
Example 2: postgresql update json field key value
UPDATE table_name SET attrs = jsonb_set(cast(attrs as jsonb), '{key}', '"new_value"', true) WHERE id = 'some_id';