def decode_filename_to_json(filename):
    """The reverse of encode_json_to_filename"""

    if "+" not in filename: return filename

    if "=" in filename:
        # Assume that it is json
        result = filename.replace("+", ':{"', 1) \
                         .replace("=", '":') \
                         .replace(",", ',"') \
                         + "}"

        if ":{" not in result:
            # there was no prepended key
            result = "{" + result
    else:
        # Not json, just a value that was passed through encode_json_to_filename
        result = filename.replace("+", ":", 1)

    return result