code: def format_to_json(data):
      
      if sys.stdout.isatty():
          return json.dumps(data, indent=4, separators=(',', ': '))
      else:
          return json.dumps(data)
docs: Converts `data` into json
      If stdout is a tty it performs a pretty print.