I have a json column with a json array in the form of
[{key : "key", value : "value"}, {key : "key2", value : "value2"}]
that I wish to convert to a new form
{"key" : "value", "key2" : "value2"}
.
I can use the following query to get rows with key
column and value
column
SELECT json_array_elements(somejson)->'key', json_array_elements(somejson)->'value' FROM temp;
However I can't seem to come up with a way to convert that to a nice key-value JSON object. Since I'm on 9.3, I can't use json_object
or json_build_object
either.