Added functionality for returning json output.