added json output and ability to save json to file