code: def value2json(obj, pretty=False, sort_keys=False, keep_whitespace=True):
      
      if FIND_LOOPS:
          obj = scrub(obj, scrub_text=_keep_whitespace if keep_whitespace else _trim_whitespace())
      try:
          json = json_encoder(obj, pretty=pretty)
          if json == None:
              Log.note(str(type(obj)) + " is not valid{{type}}JSON", type=" (pretty) " if pretty else " ")
              Log.error("Not valid JSON: " + str(obj) + " of type " + str(type(obj)))
          return json
      except Exception as e:
          e = Except.wrap(e)
          try:
              json = pypy_json_encode(obj)
              return json
          except Exception:
              pass
          Log.error("Can not encode into JSON: {{value}}", value=text_type(repr(obj)), cause=e)
docs: :param obj:  THE VALUE TO TURN INTO JSON
      :param pretty: True TO MAKE A MULTI-LINE PRETTY VERSION
      :param sort_keys: True TO SORT KEYS
      :param keep_whitespace: False TO strip() THE WHITESPACE IN THE VALUES
      :return: