import demistomock as demisto # noqa: F401 from CommonServerPython import * # noqa: F401 def extract_keys_with_values(obj, parent_key=""): """Extracts the keys with values in the JSON object""" items = [] for k, v in obj.items(): new_key = f"{parent_key}.{k}" if parent_key else k if isinstance(v, dict): items.extend(extract_keys_with_values(v, new_key)) else: items.append((new_key, v)) return items def format_data_to_table(items): """Formats the extracted data into a table format""" table = "| Key | Value |\n| Indicator Type | Indicator Values |\n" grouped_values = {} for key, value in items: if key not in grouped_values: grouped_values[key] = [value] else: grouped_values[key].append(value) for key, values in grouped_values.items(): value_str = ", ".join(f"[{v}]" for v in values) # Surround each value with square brackets table += f"| {key} | {value_str} |\n" return table def convert_to_html(markdown): html = "
| {column.strip()} | " html += "