PostgreSQL 9.3
ofrece funciones JSON ordenadas que se pueden usar para tales tareas sin definir nuevas funciones o conocer una cantidad de columnas.
SELECT id, (k).key as year, (k).value as value FROM
(SELECT j->>'id' as id, json_each_text(j) as k
FROM (
SELECT row_to_json(tbl) as j FROM tbl)
as q)
as r
WHERE (k).key <> 'id';
http://sqlfiddle.com/#!15/1714b/13