import json


def write_json_file(filename, data):
    """Write data to the file in JSON format. 
    Return True on success and False on failure.
    """

    try:
        with open(filename, "w") as file:
            json.dump(data, file, indent=2)
        return True
    except Exception as e:
        print(e)
        return False