def METHOD_NAME(file_name):
    """
    Cache (or persist) returned value of function in a json file .
    """
    def decorator(original_func):
        if not os.path.exists(file_name):
            cache = {}
        else:
            try:
                cache = json.load(open(file_name, 'rt'))
            except (IOError, ValueError):
                sys.exit(1)
        def new_func(*args):
            h = hashlib.sha1(str(original_func.__name__) + str(args)).hexdigest()
            if h not in cache:
                cache[h] = original_func(*args)
                file_dir = os.path.dirname(file_name)
                os.makedirs(file_dir, exist_ok=True)
                json.dump(cache, open(file_name, 'wt'))
            return cache[h]
        return new_func
    return decorator