code: def prepare_fields(fields):
      
      def process_item(value):
          if not isinstance(value, NUMERIC_TYPES):
              if isinstance(value, six.string_types):
                  # encode utf-8 to unicode, if necessary
                  return force_text(value)
              else:
                  if isinstance(value, dict):
                      return prepare_fields(value)
                  elif isinstance(value, list):
                      return list(map(process_item, value))
  
                  return six.text_type(value)
          return value
  
      return dict((key, process_item(value))
                  for key, value
                  in fields.items())
docs: Возвращает новый словарь с данными, подготовленными
      для сериализации в JSON.