from typing import Any
import json


def jsonify(*args: Any, **kwargs: Any) -> str:
    """
    A helper function that returns a JSON string from given arguments.

    Parameters
    ----------
    response: Optional[Union[:class:`dict`, :class:`list`]]
        The response to convert to JSON.
    **kwargs: Any
        Keyword arguments to pass to the JSON encoder.

    Returns
    -------
    :class:`str`
        The JSON string.
    """
    if args:
        response = args[0]

        if isinstance(response, list):
            if kwargs:
                ret = 'Missmatch between response and kwargs. Got list as response while kwargs is a dict'
                raise ValueError(ret)

            return json.dumps(response)

        kwargs.update(response)

    return json.dumps(kwargs)