Postgresql Plpgsql Loop Through Json Javascript Parser