#!/usr/bin/env ruby require 'rubygems' require 'json' def tag(name, content) "<#{name}>#{content}" end def row(name, array) array.map do |value| tag(name, value) end * ' ' end table_header = false puts ' ' STDIN.each_line do |line| begin object = JSON.parse(line) unless table_header puts '' table_header_row = row('th', object.keys.sort) puts tag('tr', table_header_row) table_header = true end copy = object.keys.sort.map do |key| object[key] end table_body_row = row('td', copy) puts tag('tr', table_body_row) rescue => error end end puts '
'