added first pass at json output suggested by Max