def flatten_json_output(json_data, pre_key=''):
    """
    Flatten and return a dict from a Lacework JSON structure.

    :param dict json_data: A JSON dict object.
    :param str pre_key: Optional string with the key path into the JSON object.
    :return: A dict with all elements of the JSON structure flattened.
    """
    flattened_data = {}

    for key, value in json_data.items():
        if pre_key:
            use_key = f'{pre_key}.{key}'
        else:
            use_key = key

        if isinstance(value, dict):
            new_dict = flatten_json_output(value, pre_key=use_key)
            flattened_data.update(new_dict)

        elif isinstance(value, list):
            count = 1
            for list_value in value:
                if isinstance(list_value, dict):
                    new_dict = flatten_json_output(
                        list_value, pre_key=f'{use_key}_{count}')
                    flattened_data.update(new_dict)
                else:
                    flattened_data[f'{use_key}_{count}'] = list_value
                count += 1

        else:
            flattened_data[use_key] = value

    return flattened_data