def cache_json(filename):
def cache_decorator(cacheable_function):<EOL><INDENT>@wraps(cacheable_function)<EOL>def cache_wrapper(*args, **kwargs):<EOL><INDENT>path = CACHE_DIRECTORY + filename<EOL>check_create_folder(path)<EOL>if os.path.exists(path):<EOL><INDENT>with open(path) as infile:<EOL><INDENT>return json.load(infile)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>function_output = cacheable_function(*args, **kwargs)<EOL>with open(path, '<STR_LIT:w>') as outfile:<EOL><INDENT>json.dump(function_output, outfile)<EOL><DEDENT>return function_output<EOL><DEDENT><DEDENT>return cache_wrapper<EOL><DEDENT>return cache_decorator<EOL>
Caches the JSON-serializable output of the function to a given file

    Args:
        filename (str) The filename (sans directory) to store the output

    Returns: decorator, applicable to a function that produces JSON-serializable output