def write_json(dictionary, filename):
    """Write dictionary to JSON"""
    with open(filename, 'w') as data_file:
        json.dump(dictionary, data_file, indent=4, sort_keys=True)
    print('--> Wrote ' + os.path.basename(filename))
Write dictionary to JSON