def update_json_file()

in src/scripts/utils.py [0:0]


def update_json_file(filename, new_data):
    if os.path.isfile(filename):
        with open(filename, 'r') as json_file:
            data = json.load(json_file)
            if isinstance(data, dict):
                data.update(new_data)
            elif isinstance(data, list):
                data = data + new_data
    else:
        data = new_data
    with open(filename, 'w') as json_file:
        json.dump(data, json_file, indent=2)