def get_prep_lookup(self, lookup_type, value, prepared=False):
        """ Cleanup value for the jsonb lookup types

        contains requires json encoded string
        has_any and has_all require array of string_types
        has requires string, but we can easily convert int to string

        """
        if lookup_type in ["jcontains"]:
            if not isinstance(value, six.string_types):
                value = json.dumps(value, cls=get_encoder_class(), **self._options)
        if lookup_type in ["jhas_any", "jhas_all"]:
            if isinstance(value, six.string_types):
                value = [value]
            # Quickly coerce the following:
            #   any iterable to array
            #   non-string values to strings
            value = ["%s" % v for v in value]
        elif lookup_type in ["jhas"] and not isinstance(value, six.string_types):
            if isinstance(value, six.integer_types):
                value = str(value)
            else:
                raise TypeError("jhas lookup requires str or int")
        return value
dataset/ETHPy150Open djangonauts/django-pgjson/django_pgjson/fields.py/JsonBField.get_prep_lookup/original