Convert two columns to json
Well, it would have been a lot faster and easier with 9.4, but it's doable with 9.3 in simple situations.

SELECT 
('{' ||       -- Opening brace for the JSON object
string_agg(   -- Get all the key/value pairs together in the same string
concat_ws(':', '"' || a || '"', b || ''), ',') || '}')::json -- Concatenate values to "key" : "value" format

FROM (
-- Extract the key and value from each array element
SELECT json_array_elements(myjson)-&gt;'key' a, 
json_array_elements(myjson)-&gt;'value' b FROM temp) AS FOO;


Not fun, but thankfully this is a one-time thing.

This can't be used to update a table, but you can create a temporary table and insert the values there first.