code: def encode_data(data):
      '''
      Encode data - list, dict, string, bool or int (and nested)
  
      :param data: data to encode
      :return: encoded object of the same type
      '''
      if isinstance(data, (six.string_types, bytes)):
          return encode_string(data)
      elif isinstance(data, (six.integer_types, bool, float)):
          return data
      elif data is None:
          return data
      elif isinstance(data, list):
          return [encode_data(x) for x in data]
      elif isinstance(data, dict):
          return {k: encode_data(v) for k, v in data.items()}
      else:
          raise ValueError('Cannot encode data of type %s' % type(data)f encode_data(data):
      '''
      Encode data - list, dict, string, bool or int (and nested)
  
      :param data: data to encode
      :return: encoded object of the same type
      '''
      if isinstance(data, (six.string_types, bytes)):
          return encode_string(data)
      elif isinstance(data, (six.integer_types, bool, float)):
          return data
      elif data is None:
          return data
      elif isinstance(data, list):
          return [encode_data(x) for x in data]
      elif isinstance(data, dict):
          return {k: encode_data(v) for k, v in data.items()}
      else:
          raise ValueError('Cannot encode data of type %s' % type(data))
docs: Encode data - list, dict, string, bool or int (and nested)
  
      :param data: data to encode
      :return: encoded object of the same type