5 lines
189 B
Text
5 lines
189 B
Text
create or replace function json_swap(j, a, b) as (
|
|
json_merge_patch(j, json_object(a, (j ->> b), b, (j ->> a) ))
|
|
);
|
|
|
|
select json_swap( {'a':1, 'b':2, 'c': 3}::JSON, 'a', 'b') as swapped;
|