Technical Note: [FortiSOAR / Cybersponse Tricks'n'Tips] Convert a one-dimensional list of objects to CSV
Description
The following jinja will convert a one-dimensional list of objects to CSV.
{% for key in vars.list[0].keys() -%} {{ key }}{% if not loop.last %},{% endif %} {%- endfor %}\n{% for item in vars.list -%} {% for value in item.values() -%} {{ value }}{% if not loop.last %},{% endif %} {%- endfor %}{% if not loop.last %}\n{% endif %} {%- endfor %}It assumes the list is set as vars.list.
