code: def obj_to_string(obj, top=True):
      
      obj = prepare_for_json_encoding(obj)
      if type(obj) == six.text_type:
          return obj
      return json.dumps(obj)
docs: Turn an arbitrary object into a unicode string. If complex (dict/list/tuple), will be json-encoded.