import json


def get_parameters(template):
    """
    Builds a dict of parameters from a workflow manifest.

    Parameters
    ----------
    template : dict

    Returns
    -------
    dict
        Parameters.
    """
    parameters = {}
    prefix = "PARAMETER_"
    for var in template["container"]["env"]:
        name = var["name"]
        value = var.get("value")

        if name.startswith(prefix):
            name = name[len(prefix):]

            if value is not None:
                value = json.loads(value)

            parameters[name] = value

    return parameters