import json


def decode(params):
    """ Converts a dictionary of SageMaker hyperparameters generated by `encode(...)`
        to a JSON-encodable dictionary of parameters.
    """
    result = {}
    for k, v in params.items():
        parts = k.split(".")
        k, d = parts[0], result
        for subk in parts[1:]:
            d = d.setdefault(k, {})
            k = subk
        d[k] = json.loads(v)
    return result