import json


def format_parameters(parameters: str) -> str:
    """
    Receives a key:value string and retuns a dictionary string ({"key":"value"}). In the process strips trailing and
    leading spaces.
    :param parameters: The key-value-list
    :return:
    """
    if not parameters:
        return '{}'
    pairs = []
    for item in parameters.split(','):
        try:
            key, value = item.split(':')
        except ValueError:
            raise ValueError(f"Got unexpected parameters {item}.")
        pairs.append((key.strip(), value.strip()))
    return json.dumps(dict(pairs))